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:
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],
|
||||
|
||||
Reference in new issue
Block a user