Fix ps4 no creds with additional device (#22300)

* Fix no creds with additional device.

* Update config_flow.py
pull/21823/head^2
ktnrg45 2019-03-24 17:08:59 -07:00 committed by Jason Hunter
parent 7421156dfc
commit 88df2e0ea5
1 changed files with 9 additions and 0 deletions

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: