parent
2850583085
commit
cef1809536
|
@ -65,8 +65,15 @@ class OnlineStatus(BinarySensorEntity):
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Get the status report from APCUPSd and set this entity's state."""
|
"""Get the status report from APCUPSd and set this entity's state."""
|
||||||
|
try:
|
||||||
self._data_service.update()
|
self._data_service.update()
|
||||||
|
except OSError as ex:
|
||||||
|
if self._attr_available:
|
||||||
|
self._attr_available = False
|
||||||
|
_LOGGER.exception("Got exception while fetching state: %s", ex)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._attr_available = True
|
||||||
key = self.entity_description.key.upper()
|
key = self.entity_description.key.upper()
|
||||||
if key not in self._data_service.status:
|
if key not in self._data_service.status:
|
||||||
self._attr_is_on = None
|
self._attr_is_on = None
|
||||||
|
|
|
@ -503,8 +503,15 @@ class APCUPSdSensor(SensorEntity):
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Get the latest status and use it to update our sensor state."""
|
"""Get the latest status and use it to update our sensor state."""
|
||||||
|
try:
|
||||||
self._data_service.update()
|
self._data_service.update()
|
||||||
|
except OSError as ex:
|
||||||
|
if self._attr_available:
|
||||||
|
self._attr_available = False
|
||||||
|
_LOGGER.exception("Got exception while fetching state: %s", ex)
|
||||||
|
return
|
||||||
|
|
||||||
|
self._attr_available = True
|
||||||
key = self.entity_description.key.upper()
|
key = self.entity_description.key.upper()
|
||||||
if key not in self._data_service.status:
|
if key not in self._data_service.status:
|
||||||
self._attr_native_value = None
|
self._attr_native_value = None
|
||||||
|
|
Loading…
Reference in New Issue