mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Set available state in fibaro integration (#91893)
This commit is contained in:
parent
89f1677307
commit
11accd8ba7
@ -527,6 +527,11 @@ class FibaroDevice(Entity):
|
|||||||
|
|
||||||
return attr
|
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):
|
class FibaroConnectFailed(HomeAssistantError):
|
||||||
"""Error to indicate we cannot connect to fibaro home center."""
|
"""Error to indicate we cannot connect to fibaro home center."""
|
||||||
|
@ -82,6 +82,7 @@ class FibaroBinarySensor(FibaroDevice, BinarySensorEntity):
|
|||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Get the latest data and update the state."""
|
"""Get the latest data and update the state."""
|
||||||
|
super().update()
|
||||||
if self._fibaro_sensor_type == "com.fibaro.accelerometer":
|
if self._fibaro_sensor_type == "com.fibaro.accelerometer":
|
||||||
# Accelerator sensors have values for the three axis x, y and z
|
# Accelerator sensors have values for the three axis x, y and z
|
||||||
moving_values = self._get_moving_values()
|
moving_values = self._get_moving_values()
|
||||||
|
@ -176,6 +176,7 @@ class FibaroLight(FibaroDevice, LightEntity):
|
|||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
"""Really update the state."""
|
"""Really update the state."""
|
||||||
|
super().update()
|
||||||
# Brightness handling
|
# Brightness handling
|
||||||
if brightness_supported(self.supported_color_modes):
|
if brightness_supported(self.supported_color_modes):
|
||||||
self._attr_brightness = scaleto255(self.fibaro_device.value.int_value())
|
self._attr_brightness = scaleto255(self.fibaro_device.value.int_value())
|
||||||
|
@ -52,4 +52,5 @@ class FibaroLock(FibaroDevice, LockEntity):
|
|||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
|
super().update()
|
||||||
self._attr_is_locked = self.current_binary_state
|
self._attr_is_locked = self.current_binary_state
|
||||||
|
@ -146,6 +146,7 @@ class FibaroSensor(FibaroDevice, SensorEntity):
|
|||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update the state."""
|
"""Update the state."""
|
||||||
|
super().update()
|
||||||
with suppress(TypeError):
|
with suppress(TypeError):
|
||||||
self._attr_native_value = self.fibaro_device.value.float_value()
|
self._attr_native_value = self.fibaro_device.value.float_value()
|
||||||
|
|
||||||
@ -170,6 +171,7 @@ class FibaroAdditionalSensor(FibaroDevice, SensorEntity):
|
|||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update the state."""
|
"""Update the state."""
|
||||||
|
super().update()
|
||||||
with suppress(KeyError, ValueError):
|
with suppress(KeyError, ValueError):
|
||||||
self._attr_native_value = convert(
|
self._attr_native_value = convert(
|
||||||
self.fibaro_device.properties[self.entity_description.key],
|
self.fibaro_device.properties[self.entity_description.key],
|
||||||
|
@ -52,4 +52,5 @@ class FibaroSwitch(FibaroDevice, SwitchEntity):
|
|||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Update device state."""
|
"""Update device state."""
|
||||||
|
super().update()
|
||||||
self._attr_is_on = self.current_binary_state
|
self._attr_is_on = self.current_binary_state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user