1 """Support for ASUSWRT devices."""
7 from .router
import AsusWrtRouter
9 PLATFORMS = [Platform.DEVICE_TRACKER, Platform.SENSOR]
11 type AsusWrtConfigEntry = ConfigEntry[AsusWrtRouter]
15 """Set up AsusWrt platform."""
20 router.async_on_close(entry.add_update_listener(update_listener))
22 async
def async_close_connection(event: Event) ->
None:
23 """Close AsusWrt connection on HA Stop."""
26 entry.async_on_unload(
27 hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, async_close_connection)
30 entry.runtime_data = router
32 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
38 """Unload a config entry."""
39 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
40 router = entry.runtime_data
46 async
def update_listener(hass: HomeAssistant, entry: AsusWrtConfigEntry) ->
None:
47 """Update when config_entry options update."""
48 router = entry.runtime_data
50 if router.update_options(entry.options):
51 await hass.config_entries.async_reload(entry.entry_id)
None update_listener(HomeAssistant hass, AsusWrtConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, AsusWrtConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, AsusWrtConfigEntry entry)