Cleanly stop tradfri on shutdown (#17114)
* Tradfri shutdown fix * Bump version * Bump version * Fix * Derp * Remove unnecessary shutdown event
This commit is contained in:
parent
aec320dc19
commit
4218efddcd
4 changed files with 14 additions and 3 deletions
|
@ -9,6 +9,7 @@ import logging
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.util.json import load_json
|
||||
|
||||
|
@ -17,7 +18,7 @@ from .const import (
|
|||
|
||||
from . import config_flow # noqa pylint_disable=unused-import
|
||||
|
||||
REQUIREMENTS = ['pytradfri[async]==5.6.0']
|
||||
REQUIREMENTS = ['pytradfri[async]==6.0.1']
|
||||
|
||||
DOMAIN = 'tradfri'
|
||||
CONFIG_FILE = '.tradfri_psk.conf'
|
||||
|
@ -87,6 +88,13 @@ async def async_setup_entry(hass, entry):
|
|||
psk=entry.data[CONF_KEY],
|
||||
loop=hass.loop
|
||||
)
|
||||
|
||||
async def on_hass_stop(event):
|
||||
"""Close connection when hass stops."""
|
||||
await factory.shutdown()
|
||||
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop)
|
||||
|
||||
api = factory.request
|
||||
gateway = Gateway()
|
||||
|
||||
|
|
|
@ -166,9 +166,12 @@ async def get_gateway_info(hass, host, identity, key):
|
|||
psk=key,
|
||||
loop=hass.loop
|
||||
)
|
||||
|
||||
api = factory.request
|
||||
gateway = Gateway()
|
||||
gateway_info_result = await api(gateway.get_gateway_info())
|
||||
|
||||
await factory.shutdown()
|
||||
except (OSError, RequestError):
|
||||
# We're also catching OSError as PyTradfri doesn't catch that one yet
|
||||
# Upstream PR: https://github.com/ggravlingen/pytradfri/pull/189
|
||||
|
|
|
@ -1217,7 +1217,7 @@ pytouchline==0.7
|
|||
pytrackr==0.0.5
|
||||
|
||||
# homeassistant.components.tradfri
|
||||
pytradfri[async]==5.6.0
|
||||
pytradfri[async]==6.0.1
|
||||
|
||||
# homeassistant.components.sensor.trafikverket_weatherstation
|
||||
pytrafikverket==0.1.5.8
|
||||
|
|
|
@ -188,7 +188,7 @@ python-nest==4.0.3
|
|||
pythonwhois==2.4.3
|
||||
|
||||
# homeassistant.components.tradfri
|
||||
pytradfri[async]==5.6.0
|
||||
pytradfri[async]==6.0.1
|
||||
|
||||
# homeassistant.components.device_tracker.unifi
|
||||
pyunifi==2.13
|
||||
|
|
Loading…
Add table
Reference in a new issue