1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Improve PS4 media art fetching and config flow (#22167)

* improved config flow

* Added errors, docs url

* Added errors, docs url

* Added manual config mode

* Add tests for manual/auto host input

* fix inline docs

* fix inline docs

* Changed region list

* Added deprecated region message

* removed DEFAULT_REGION

* Added close method

* Fixes

* Update const.py

* Update const.py

* Update const.py

* Update test_config_flow.py

* Added invalid pin errors

* Update strings.json

* Update strings.json

* bump pyps4 to 0.5.0

* Bump pyps4 0.5.0

* Bump pyps4 to 0.5.0

* test fixes

* pylint

* Change error reference

* remove pin messages

* remove pin messages

* Update en.json

* remove pin tests

* fix tests

* update vol

* Vol fix

* Update config_flow.py

* Add migration for v1 entry

* lint

* fixes

* typo

* fix

* Update config_flow.py

* Fix vol

* Executor job for io method.

* Update __init__.py

* blank line

* Update __init__.py

* Update tests/components/ps4/test_config_flow.py

Co-Authored-By: ktnrg45 <38207570+ktnrg45@users.noreply.github.com>
This commit is contained in:
ktnrg45
2019-03-25 05:25:15 -07:00
committed by Charles Garwood
parent 96133f5e6b
commit 17a96c6d9b
9 changed files with 227 additions and 71 deletions

View File

@@ -20,7 +20,7 @@ from homeassistant.const import (
import homeassistant.helpers.config_validation as cv
from homeassistant.util.json import load_json, save_json
from .const import DOMAIN as PS4_DOMAIN
from .const import DOMAIN as PS4_DOMAIN, REGIONS as deprecated_regions
DEPENDENCIES = ['ps4']
@@ -142,6 +142,12 @@ class PS4Device(MediaPlayerDevice):
self._games = self.load_games()
if self._games is not None:
self._source_list = list(sorted(self._games.values()))
# Non-Breaking although data returned may be inaccurate.
if self._region in deprecated_regions:
_LOGGER.info("""Region: %s has been deprecated.
Please remove PS4 integration
and Re-configure again to utilize
current regions""", self._region)
except socket.timeout:
status = None
if status is not None:
@@ -275,6 +281,8 @@ class PS4Device(MediaPlayerDevice):
async def async_will_remove_from_hass(self):
"""Remove Entity from Hass."""
# Close TCP Socket
await self.hass.async_add_executor_job(self._ps4.close)
self.hass.data[PS4_DATA].devices.remove(self)
@property
@@ -320,6 +328,7 @@ class PS4Device(MediaPlayerDevice):
@property
def media_content_type(self):
"""Content type of current playing media."""
# No MEDIA_TYPE_GAME attr as of 0.90.
return MEDIA_TYPE_MUSIC
@property