Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Ps4 Convert entity to Async / Fix entity name changing #24101

Merged
merged 31 commits into from Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion homeassistant/components/ps4/__init__.py
Expand Up @@ -7,13 +7,29 @@
from homeassistant.util import location

from .config_flow import PlayStation4FlowHandler # noqa: pylint: disable=unused-import
from .const import DOMAIN # noqa: pylint: disable=unused-import
from .const import DOMAIN, PS4_DATA # noqa: pylint: disable=unused-import

_LOGGER = logging.getLogger(__name__)


class PS4Data():
"""Init Data Class."""

def __init__(self):
"""Init Class."""
self.devices = []
self.protocol = None


async def async_setup(hass, config):
"""Set up the PS4 Component."""
from pyps4_homeassistant.ddp import async_create_ddp_endpoint

hass.data[PS4_DATA] = PS4Data()

transport, protocol = await async_create_ddp_endpoint()
hass.data[PS4_DATA].protocol = protocol
_LOGGER.debug("PS4 DDP endpoint created: %s, %s", transport, protocol)
return True


Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/ps4/config_flow.py
Expand Up @@ -9,7 +9,7 @@
CONF_CODE, CONF_HOST, CONF_IP_ADDRESS, CONF_NAME, CONF_REGION, CONF_TOKEN)
from homeassistant.util import location

from .const import DEFAULT_NAME, DOMAIN
from .const import DEFAULT_ALIAS, DEFAULT_NAME, DOMAIN

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -61,7 +61,7 @@ async def async_step_creds(self, user_input=None):
if user_input is not None:
try:
self.creds = await self.hass.async_add_executor_job(
self.helper.get_creds)
self.helper.get_creds, DEFAULT_ALIAS)
if self.creds is not None:
return await self.async_step_mode()
return self.async_abort(reason='credential_error')
Expand Down Expand Up @@ -143,7 +143,8 @@ async def async_step_link(self, user_input=None):
self.host = user_input[CONF_IP_ADDRESS]

is_ready, is_login = await self.hass.async_add_executor_job(
self.helper.link, self.host, self.creds, self.pin)
self.helper.link, self.host,
self.creds, self.pin, DEFAULT_ALIAS)

if is_ready is False:
errors['base'] = 'not_ready'
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/ps4/const.py
@@ -1,7 +1,9 @@
"""Constants for PlayStation 4."""
DEFAULT_NAME = "PlayStation 4"
DEFAULT_REGION = "United States"
DEFAULT_ALIAS = 'Home-Assistant'
DOMAIN = 'ps4'
PS4_DATA = 'ps4_data'

# Deprecated used for logger/backwards compatibility from 0.89
REGIONS = ['R1', 'R2', 'R3', 'R4', 'R5']
2 changes: 1 addition & 1 deletion homeassistant/components/ps4/manifest.json
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/components/ps4",
"requirements": [
"pyps4-homeassistant==0.7.3"
"pyps4-homeassistant==0.8.2"
],
"dependencies": [],
"codeowners": [
Expand Down