1 """Support for Netgear routers."""
3 from __future__
import annotations
13 from .const
import DEVICE_ICONS, DOMAIN, KEY_COORDINATOR, KEY_ROUTER
14 from .entity
import NetgearDeviceEntity
15 from .router
import NetgearRouter
17 _LOGGER = logging.getLogger(__name__)
21 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
23 """Set up device tracker for Netgear component."""
24 router = hass.data[DOMAIN][entry.entry_id][KEY_ROUTER]
25 coordinator = hass.data[DOMAIN][entry.entry_id][KEY_COORDINATOR]
29 def new_device_callback() -> None:
30 """Add new devices if needed."""
31 if not coordinator.data:
36 for mac, device
in router.devices.items():
45 entry.async_on_unload(coordinator.async_add_listener(new_device_callback))
47 coordinator.data =
True
52 """Representation of a device connected to a Netgear router."""
54 _attr_has_entity_name =
False
57 self, coordinator: DataUpdateCoordinator, router: NetgearRouter, device: dict
59 """Initialize a Netgear device."""
60 super().
__init__(coordinator, router, device)
62 self.
_icon_icon = DEVICE_ICONS.get(device[
"device_type"],
"mdi:help-network")
66 """Return the hostname of the given device or None if we don't know."""
74 """Update the Netgear device."""
77 self.
_icon_icon = DEVICE_ICONS.get(self.
_device_device_device[
"device_type"],
"mdi:help-network")
81 """Return true if the device is connected to the router."""
86 """Return the IP address."""
91 """Return the mac address."""
96 """Return the hostname."""
101 """Return the icon."""
102 return self.
_icon_icon
None async_update_device(self)
None __init__(self, DataUpdateCoordinator coordinator, NetgearRouter router, dict device)
str|None get_hostname(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)