Handle missing value in all platforms of zwave_js (#46081)
This commit is contained in:
parent
fb68bf85ae
commit
242ff045b9
6 changed files with 41 additions and 14 deletions
|
@ -84,13 +84,19 @@ class ZwaveFan(ZWaveBaseEntity, FanEntity):
|
|||
await self.info.node.async_set_value(target_value, 0)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
def is_on(self) -> Optional[bool]: # type: ignore
|
||||
"""Return true if device is on (speed above 0)."""
|
||||
if self.info.primary_value.value is None:
|
||||
# guard missing value
|
||||
return None
|
||||
return bool(self.info.primary_value.value > 0)
|
||||
|
||||
@property
|
||||
def percentage(self) -> int:
|
||||
def percentage(self) -> Optional[int]:
|
||||
"""Return the current speed percentage."""
|
||||
if self.info.primary_value.value is None:
|
||||
# guard missing value
|
||||
return None
|
||||
return ranged_value_to_percentage(SPEED_RANGE, self.info.primary_value.value)
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue