Set available state in fibaro integration (#91893)
parent
89f1677307
commit
11accd8ba7
|
@ -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."""
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue