Close androidtv ADB socket connection when Home Assistant stops (#37973)

* Close the ADB connection on HA stop

* Get the test to pass

* Remove unnecessary test code

* Register the callback sooner

* '_async_stop' -> 'async_close'

* 'async_close' method -> '_async_close' function
This commit is contained in:
Jeff Irion authored and GitHub committed 2020-07-20 02:48:08 +02:00
1 parent 967a168ab7
commit 2c3618e2c7
2 files changed
+28

No files matched your search

@@ -40,6 +40,7 @@ from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PORT,
EVENT_HOMEASSISTANT_STOP,
STATE_IDLE,
STATE_OFF,
STATE_PAUSED,
@@ -230,6 +231,13 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
)
raise PlatformNotReady
async def _async_close(event):
"""Close the ADB socket connection when HA stops."""
await aftv.adb_close()
# Close the ADB connection when HA stops
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_close)
device_args = [
aftv,
config[CONF_NAME],