mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
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
@ -9,6 +9,7 @@ import logging
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util.json import load_json
|
from homeassistant.util.json import load_json
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ from .const import (
|
|||||||
|
|
||||||
from . import config_flow # noqa pylint_disable=unused-import
|
from . import config_flow # noqa pylint_disable=unused-import
|
||||||
|
|
||||||
REQUIREMENTS = ['pytradfri[async]==5.6.0']
|
REQUIREMENTS = ['pytradfri[async]==6.0.1']
|
||||||
|
|
||||||
DOMAIN = 'tradfri'
|
DOMAIN = 'tradfri'
|
||||||
CONFIG_FILE = '.tradfri_psk.conf'
|
CONFIG_FILE = '.tradfri_psk.conf'
|
||||||
@ -87,6 +88,13 @@ async def async_setup_entry(hass, entry):
|
|||||||
psk=entry.data[CONF_KEY],
|
psk=entry.data[CONF_KEY],
|
||||||
loop=hass.loop
|
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
|
api = factory.request
|
||||||
gateway = Gateway()
|
gateway = Gateway()
|
||||||
|
|
||||||
|
@ -166,9 +166,12 @@ async def get_gateway_info(hass, host, identity, key):
|
|||||||
psk=key,
|
psk=key,
|
||||||
loop=hass.loop
|
loop=hass.loop
|
||||||
)
|
)
|
||||||
|
|
||||||
api = factory.request
|
api = factory.request
|
||||||
gateway = Gateway()
|
gateway = Gateway()
|
||||||
gateway_info_result = await api(gateway.get_gateway_info())
|
gateway_info_result = await api(gateway.get_gateway_info())
|
||||||
|
|
||||||
|
await factory.shutdown()
|
||||||
except (OSError, RequestError):
|
except (OSError, RequestError):
|
||||||
# We're also catching OSError as PyTradfri doesn't catch that one yet
|
# We're also catching OSError as PyTradfri doesn't catch that one yet
|
||||||
# Upstream PR: https://github.com/ggravlingen/pytradfri/pull/189
|
# Upstream PR: https://github.com/ggravlingen/pytradfri/pull/189
|
||||||
|
@ -1217,7 +1217,7 @@ pytouchline==0.7
|
|||||||
pytrackr==0.0.5
|
pytrackr==0.0.5
|
||||||
|
|
||||||
# homeassistant.components.tradfri
|
# homeassistant.components.tradfri
|
||||||
pytradfri[async]==5.6.0
|
pytradfri[async]==6.0.1
|
||||||
|
|
||||||
# homeassistant.components.sensor.trafikverket_weatherstation
|
# homeassistant.components.sensor.trafikverket_weatherstation
|
||||||
pytrafikverket==0.1.5.8
|
pytrafikverket==0.1.5.8
|
||||||
|
@ -188,7 +188,7 @@ python-nest==4.0.3
|
|||||||
pythonwhois==2.4.3
|
pythonwhois==2.4.3
|
||||||
|
|
||||||
# homeassistant.components.tradfri
|
# homeassistant.components.tradfri
|
||||||
pytradfri[async]==5.6.0
|
pytradfri[async]==6.0.1
|
||||||
|
|
||||||
# homeassistant.components.device_tracker.unifi
|
# homeassistant.components.device_tracker.unifi
|
||||||
pyunifi==2.13
|
pyunifi==2.13
|
||||||
|
Loading…
x
Reference in New Issue
Block a user