Cloud cognito switch (#10823)

* Allow email based cognito instance

* Fix quitting Home Assistant while reconnecting

* Lint
This commit is contained in:
Paulus Schoutsen 2017-11-27 01:09:17 -08:00 committed by Pascal Vizeli
parent 1b7a64412d
commit fe0a9529ed
5 changed files with 60 additions and 24 deletions

View file

@ -59,13 +59,6 @@ class CloudIoT:
if self.state == STATE_CONNECTED:
raise RuntimeError('Already connected')
self.state = STATE_CONNECTING
self.close_requested = False
remove_hass_stop_listener = None
session = async_get_clientsession(self.cloud.hass)
client = None
disconnect_warn = None
@asyncio.coroutine
def _handle_hass_stop(event):
"""Handle Home Assistant shutting down."""
@ -73,6 +66,14 @@ class CloudIoT:
remove_hass_stop_listener = None
yield from self.disconnect()
self.state = STATE_CONNECTING
self.close_requested = False
remove_hass_stop_listener = hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STOP, _handle_hass_stop)
session = async_get_clientsession(self.cloud.hass)
client = None
disconnect_warn = None
try:
yield from hass.async_add_job(auth_api.check_token, self.cloud)
@ -83,9 +84,6 @@ class CloudIoT:
})
self.tries = 0
remove_hass_stop_listener = hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STOP, _handle_hass_stop)
_LOGGER.info('Connected')
self.state = STATE_CONNECTED