mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix available for Mill (#58510)
This commit is contained in:
parent
ac08d05b76
commit
91b07cce20
@ -84,6 +84,8 @@ class MillHeater(CoordinatorEntity, ClimateEntity):
|
||||
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._available = False
|
||||
|
||||
self._id = heater.device_id
|
||||
self._attr_unique_id = heater.device_id
|
||||
self._attr_name = heater.name
|
||||
@ -131,6 +133,11 @@ class MillHeater(CoordinatorEntity, ClimateEntity):
|
||||
)
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return super().available and self._available
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
@ -139,7 +146,7 @@ class MillHeater(CoordinatorEntity, ClimateEntity):
|
||||
|
||||
@callback
|
||||
def _update_attr(self, heater):
|
||||
self._attr_available = heater.available
|
||||
self._available = heater.available
|
||||
self._attr_extra_state_attributes = {
|
||||
"open_window": heater.open_window,
|
||||
"heating": heater.is_heating,
|
||||
|
@ -124,6 +124,7 @@ class MillSensor(CoordinatorEntity, SensorEntity):
|
||||
|
||||
self._id = mill_device.device_id
|
||||
self.entity_description = entity_description
|
||||
self._available = False
|
||||
|
||||
self._attr_name = f"{mill_device.name} {entity_description.name}"
|
||||
self._attr_unique_id = f"{mill_device.device_id}_{entity_description.key}"
|
||||
@ -144,7 +145,12 @@ class MillSensor(CoordinatorEntity, SensorEntity):
|
||||
self._update_attr(self.coordinator.data[self._id])
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
return super().available and self._available
|
||||
|
||||
@callback
|
||||
def _update_attr(self, device):
|
||||
self._attr_available = device.available
|
||||
self._available = device.available
|
||||
self._attr_native_value = getattr(device, self.entity_description.key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user