mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Add Netgear ssid and conn_ap_mac sensors (#57226)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
9040b6a59e
commit
1fbc94f56d
@ -120,7 +120,7 @@ class NetgearRouter:
|
|||||||
self.device_name = None
|
self.device_name = None
|
||||||
self.firmware_version = None
|
self.firmware_version = None
|
||||||
|
|
||||||
self._method_version = 1
|
self.method_version = 1
|
||||||
consider_home_int = entry.options.get(
|
consider_home_int = entry.options.get(
|
||||||
CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOME.total_seconds()
|
CONF_CONSIDER_HOME, DEFAULT_CONSIDER_HOME.total_seconds()
|
||||||
)
|
)
|
||||||
@ -148,7 +148,7 @@ class NetgearRouter:
|
|||||||
|
|
||||||
for model in MODELS_V2:
|
for model in MODELS_V2:
|
||||||
if self.model.startswith(model):
|
if self.model.startswith(model):
|
||||||
self._method_version = 2
|
self.method_version = 2
|
||||||
|
|
||||||
async def async_setup(self) -> None:
|
async def async_setup(self) -> None:
|
||||||
"""Set up a Netgear router."""
|
"""Set up a Netgear router."""
|
||||||
@ -186,7 +186,7 @@ class NetgearRouter:
|
|||||||
|
|
||||||
async def async_get_attached_devices(self) -> list:
|
async def async_get_attached_devices(self) -> list:
|
||||||
"""Get the devices connected to the router."""
|
"""Get the devices connected to the router."""
|
||||||
if self._method_version == 1:
|
if self.method_version == 1:
|
||||||
return await self.hass.async_add_executor_job(
|
return await self.hass.async_add_executor_job(
|
||||||
self._api.get_attached_devices
|
self._api.get_attached_devices
|
||||||
)
|
)
|
||||||
|
@ -21,14 +21,11 @@ SENSOR_TYPES = {
|
|||||||
"type": SensorEntityDescription(
|
"type": SensorEntityDescription(
|
||||||
key="type",
|
key="type",
|
||||||
name="link type",
|
name="link type",
|
||||||
native_unit_of_measurement=None,
|
|
||||||
device_class=None,
|
|
||||||
),
|
),
|
||||||
"link_rate": SensorEntityDescription(
|
"link_rate": SensorEntityDescription(
|
||||||
key="link_rate",
|
key="link_rate",
|
||||||
name="link rate",
|
name="link rate",
|
||||||
native_unit_of_measurement="Mbps",
|
native_unit_of_measurement="Mbps",
|
||||||
device_class=None,
|
|
||||||
),
|
),
|
||||||
"signal": SensorEntityDescription(
|
"signal": SensorEntityDescription(
|
||||||
key="signal",
|
key="signal",
|
||||||
@ -36,6 +33,14 @@ SENSOR_TYPES = {
|
|||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
|
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||||
),
|
),
|
||||||
|
"ssid": SensorEntityDescription(
|
||||||
|
key="ssid",
|
||||||
|
name="ssid",
|
||||||
|
),
|
||||||
|
"conn_ap_mac": SensorEntityDescription(
|
||||||
|
key="conn_ap_mac",
|
||||||
|
name="access point mac",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,10 +50,11 @@ async def async_setup_entry(
|
|||||||
"""Set up device tracker for Netgear component."""
|
"""Set up device tracker for Netgear component."""
|
||||||
|
|
||||||
def generate_sensor_classes(router: NetgearRouter, device: dict):
|
def generate_sensor_classes(router: NetgearRouter, device: dict):
|
||||||
return [
|
sensors = ["type", "link_rate", "signal"]
|
||||||
NetgearSensorEntity(router, device, attribute)
|
if router.method_version == 2:
|
||||||
for attribute in ("type", "link_rate", "signal")
|
sensors.extend(["ssid", "conn_ap_mac"])
|
||||||
]
|
|
||||||
|
return [NetgearSensorEntity(router, device, attribute) for attribute in sensors]
|
||||||
|
|
||||||
async_setup_netgear_entry(hass, entry, async_add_entities, generate_sensor_classes)
|
async_setup_netgear_entry(hass, entry, async_add_entities, generate_sensor_classes)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user