Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion homeassistant/components/tradfri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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

Expand All @@ -17,7 +18,7 @@

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'
Expand Down Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/tradfri/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,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
Expand Down