Netgear allow to remove old devices (#87849)

This commit is contained in:
starkillerOG 2023-02-12 21:45:54 +01:00 committed by GitHub
parent f96e8c82e8
commit 168d307762
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -203,3 +203,24 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
"""Handle options update."""
await hass.config_entries.async_reload(config_entry.entry_id)
async def async_remove_config_entry_device(
hass: HomeAssistant, config_entry: ConfigEntry, device_entry: dr.DeviceEntry
) -> bool:
"""Remove a config entry from a device."""
router = hass.data[DOMAIN][config_entry.entry_id][KEY_ROUTER]
device_mac = None
for connection in device_entry.connections:
if connection[0] == "mac":
device_mac = connection[1]
break
if device_mac is None:
return False
if device_mac not in router.devices:
return True
return not router.devices[device_mac]["active"]