1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Fix ps4 no creds with additional device (#22300)

* Fix no creds with additional device.

* Update config_flow.py
This commit is contained in:
ktnrg45 2019-03-24 17:08:59 -07:00 committed by Paulus Schoutsen
parent 8085e9206a
commit 4d0a28fa56

View File

@ -79,7 +79,11 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow):
# If entry exists check that devices found aren't configured.
if self.hass.config_entries.async_entries(DOMAIN):
creds = {}
for entry in self.hass.config_entries.async_entries(DOMAIN):
# Retrieve creds from entry
creds['data'] = entry.data[CONF_TOKEN]
# Retrieve device data from entry
conf_devices = entry.data['devices']
for c_device in conf_devices:
if c_device['host'] in device_list:
@ -88,6 +92,11 @@ class PlayStation4FlowHandler(config_entries.ConfigFlow):
# If list is empty then all devices are configured.
if not device_list:
return self.async_abort(reason='devices_configured')
# Add existing creds for linking. Should be only 1.
if not creds:
# Abort if creds is missing.
return self.async_abort(reason='credential_error')
self.creds = creds['data']
# Login to PS4 with user data.
if user_input is not None: