Add tests for Fritz!Tools sensors (#67776)

This commit is contained in:
Michael 2022-03-30 01:54:16 +02:00 committed by GitHub
parent 94c5dbfd16
commit 3d64d1b76b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 165 additions and 9 deletions

View file

@ -308,14 +308,13 @@ class FritzBoxSensor(FritzBoxBaseEntity, SensorEntity):
"""Update data."""
_LOGGER.debug("Updating FRITZ!Box sensors")
status: FritzStatus = self._avm_wrapper.fritz_status
try:
status: FritzStatus = self._avm_wrapper.fritz_status
self._attr_available = True
self._attr_native_value = (
self._last_device_value
) = self.entity_description.value_fn(status, self._last_device_value)
except FritzConnectionException:
_LOGGER.error("Error getting the state from the FRITZ!Box", exc_info=True)
self._attr_available = False
return
self._attr_native_value = (
self._last_device_value
) = self.entity_description.value_fn(status, self._last_device_value)
self._attr_available = True