Set available state in fibaro integration (#91893)

This commit is contained in:
rappenze 2023-05-24 14:54:10 +02:00 committed by GitHub
parent 89f1677307
commit 11accd8ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 0 deletions

View File

@ -527,6 +527,11 @@ class FibaroDevice(Entity):
return attr
def update(self) -> None:
"""Update the available state of the entity."""
if isinstance(self.fibaro_device, DeviceModel) and self.fibaro_device.has_dead:
self._attr_available = not self.fibaro_device.dead
class FibaroConnectFailed(HomeAssistantError):
"""Error to indicate we cannot connect to fibaro home center."""

View File

@ -82,6 +82,7 @@ class FibaroBinarySensor(FibaroDevice, BinarySensorEntity):
def update(self) -> None:
"""Get the latest data and update the state."""
super().update()
if self._fibaro_sensor_type == "com.fibaro.accelerometer":
# Accelerator sensors have values for the three axis x, y and z
moving_values = self._get_moving_values()

View File

@ -176,6 +176,7 @@ class FibaroLight(FibaroDevice, LightEntity):
def _update(self):
"""Really update the state."""
super().update()
# Brightness handling
if brightness_supported(self.supported_color_modes):
self._attr_brightness = scaleto255(self.fibaro_device.value.int_value())

View File

@ -52,4 +52,5 @@ class FibaroLock(FibaroDevice, LockEntity):
def update(self) -> None:
"""Update device state."""
super().update()
self._attr_is_locked = self.current_binary_state

View File

@ -146,6 +146,7 @@ class FibaroSensor(FibaroDevice, SensorEntity):
def update(self) -> None:
"""Update the state."""
super().update()
with suppress(TypeError):
self._attr_native_value = self.fibaro_device.value.float_value()
@ -170,6 +171,7 @@ class FibaroAdditionalSensor(FibaroDevice, SensorEntity):
def update(self) -> None:
"""Update the state."""
super().update()
with suppress(KeyError, ValueError):
self._attr_native_value = convert(
self.fibaro_device.properties[self.entity_description.key],

View File

@ -52,4 +52,5 @@ class FibaroSwitch(FibaroDevice, SwitchEntity):
def update(self) -> None:
"""Update device state."""
super().update()
self._attr_is_on = self.current_binary_state