Fix apcupsd spamming logs when host is unavailable (#85920)
fixes undefined
This commit is contained in:
parent
2850583085
commit
cef1809536
2 changed files with 16 additions and 2 deletions
|
@ -65,8 +65,15 @@ class OnlineStatus(BinarySensorEntity):
|
|||
|
||||
def update(self) -> None:
|
||||
"""Get the status report from APCUPSd and set this entity's state."""
|
||||
self._data_service.update()
|
||||
try:
|
||||
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()
|
||||
if key not in self._data_service.status:
|
||||
self._attr_is_on = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue