mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Set Netgear device entities to unavailable when the device is not connected (#135362)
This commit is contained in:
parent
507239c661
commit
2617575e18
@ -210,6 +210,12 @@ class NetgearRouter:
|
||||
|
||||
for device in self.devices.values():
|
||||
device["active"] = now - device["last_seen"] <= self._consider_home
|
||||
if not device["active"]:
|
||||
device["link_rate"] = None
|
||||
device["signal"] = None
|
||||
device["ip"] = None
|
||||
device["ssid"] = None
|
||||
device["conn_ap_mac"] = None
|
||||
|
||||
if new_device:
|
||||
_LOGGER.debug("Netgear tracker: new device found")
|
||||
|
@ -344,6 +344,11 @@ class NetgearSensorEntity(NetgearDeviceEntity, SensorEntity):
|
||||
self._attr_unique_id = f"{self._mac}-{attribute}"
|
||||
self._state = device.get(attribute)
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return if entity is available."""
|
||||
return super().available and self._device.get(self._attribute) is not None
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
"""Return the state of the sensor."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user