mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +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():
|
for device in self.devices.values():
|
||||||
device["active"] = now - device["last_seen"] <= self._consider_home
|
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:
|
if new_device:
|
||||||
_LOGGER.debug("Netgear tracker: new device found")
|
_LOGGER.debug("Netgear tracker: new device found")
|
||||||
|
@ -344,6 +344,11 @@ class NetgearSensorEntity(NetgearDeviceEntity, SensorEntity):
|
|||||||
self._attr_unique_id = f"{self._mac}-{attribute}"
|
self._attr_unique_id = f"{self._mac}-{attribute}"
|
||||||
self._state = device.get(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
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user