mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Use entry.async_on_unload in gpslogger (#144883)
This commit is contained in:
parent
993e98a43f
commit
a9238c7577
@ -90,7 +90,7 @@ async def handle_webhook(
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Configure based on config entry."""
|
||||
hass.data.setdefault(DOMAIN, {"devices": set(), "unsub_device_tracker": {}})
|
||||
hass.data.setdefault(DOMAIN, {"devices": set()})
|
||||
webhook.async_register(
|
||||
hass, DOMAIN, "GPSLogger", entry.data[CONF_WEBHOOK_ID], handle_webhook
|
||||
)
|
||||
@ -103,7 +103,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
webhook.async_unregister(hass, entry.data[CONF_WEBHOOK_ID])
|
||||
hass.data[DOMAIN]["unsub_device_tracker"].pop(entry.entry_id)()
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
||||
|
||||
|
@ -42,9 +42,7 @@ async def async_setup_entry(
|
||||
|
||||
async_add_entities([GPSLoggerEntity(device, gps, battery, accuracy, attrs)])
|
||||
|
||||
hass.data[DOMAIN]["unsub_device_tracker"][entry.entry_id] = (
|
||||
async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data)
|
||||
)
|
||||
entry.async_on_unload(async_dispatcher_connect(hass, TRACKER_UPDATE, _receive_data))
|
||||
|
||||
# Restore previously loaded devices
|
||||
dev_reg = dr.async_get(hass)
|
||||
|
Loading…
x
Reference in New Issue
Block a user