mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Handle/extend number entity availability property in HomeWizard Energy (#102934)
This commit is contained in:
parent
923d2d0d81
commit
fd1c1dba7c
@ -47,13 +47,17 @@ class HWEnergyNumberEntity(HomeWizardEntity, NumberEntity):
|
|||||||
await self.coordinator.api.state_set(brightness=int(value * (255 / 100)))
|
await self.coordinator.api.state_set(brightness=int(value * (255 / 100)))
|
||||||
await self.coordinator.async_refresh()
|
await self.coordinator.async_refresh()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return if entity is available."""
|
||||||
|
return super().available and self.coordinator.data.state is not None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
"""Return the current value."""
|
"""Return the current value."""
|
||||||
if (
|
if (
|
||||||
self.coordinator.data.state is None
|
not self.coordinator.data.state
|
||||||
or self.coordinator.data.state.brightness is None
|
or (brightness := self.coordinator.data.state.brightness) is None
|
||||||
):
|
):
|
||||||
return None
|
return None
|
||||||
brightness: float = self.coordinator.data.state.brightness
|
|
||||||
return round(brightness * (100 / 255))
|
return round(brightness * (100 / 255))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user