1 """Represent the Netgear router and its devices."""
3 from __future__
import annotations
5 from abc
import abstractmethod
14 DataUpdateCoordinator,
17 from .const
import DOMAIN
18 from .router
import NetgearRouter
22 """Base class for a device connected to a Netgear router."""
24 _attr_has_entity_name =
True
27 self, coordinator: DataUpdateCoordinator, router: NetgearRouter, device: dict
29 """Initialize a Netgear device."""
33 self.
_mac_mac = device[
"mac"]
38 connections={(dr.CONNECTION_NETWORK_MAC, self.
_mac_mac)},
40 default_model=device[
"device_model"],
41 via_device=(DOMAIN, router.unique_id),
45 """Return the name of the given device or the MAC if we don't know."""
46 name = self.
_device_device[
"name"]
47 if not name
or name ==
"--":
55 """Update the Netgear device."""
59 """Handle updated data from the coordinator."""
65 """Base class for a Netgear router entity without coordinator."""
67 _attr_has_entity_name =
True
69 def __init__(self, router: NetgearRouter) ->
None:
70 """Initialize a Netgear device."""
73 configuration_url =
None
74 if host := router.entry.data[CONF_HOST]:
75 configuration_url = f
"http://{host}/"
79 identifiers={(DOMAIN, router.unique_id)},
80 manufacturer=
"Netgear",
81 name=router.device_name,
83 sw_version=router.firmware_version,
84 hw_version=router.hardware_version,
85 configuration_url=configuration_url,
90 """Base class for a Netgear router entity."""
93 self, coordinator: DataUpdateCoordinator, router: NetgearRouter
95 """Initialize a Netgear device."""
96 CoordinatorEntity.__init__(self, coordinator)
97 NetgearRouterEntity.__init__(self, router)
102 """Update the Netgear device."""
106 """Handle updated data from the coordinator."""
def get_device_name(self)
None __init__(self, DataUpdateCoordinator coordinator, NetgearRouter router, dict device)
None async_update_device(self)
None _handle_coordinator_update(self)
None _handle_coordinator_update(self)
None async_update_device(self)
None __init__(self, DataUpdateCoordinator coordinator, NetgearRouter router)
None __init__(self, NetgearRouter router)