mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 08:07:45 +00:00
Add guards for missing value in binary_sensor platform of zwave_js integration (#46293)
This commit is contained in:
parent
1c2f72a453
commit
70af3e4776
@ -258,8 +258,10 @@ class ZWaveBooleanBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||||||
"""Representation of a Z-Wave binary_sensor."""
|
"""Representation of a Z-Wave binary_sensor."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> Optional[bool]:
|
||||||
"""Return if the sensor is on or off."""
|
"""Return if the sensor is on or off."""
|
||||||
|
if self.info.primary_value.value is None:
|
||||||
|
return None
|
||||||
return bool(self.info.primary_value.value)
|
return bool(self.info.primary_value.value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -301,8 +303,10 @@ class ZWaveNotificationBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||||||
self._mapping_info = self._get_sensor_mapping()
|
self._mapping_info = self._get_sensor_mapping()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> Optional[bool]:
|
||||||
"""Return if the sensor is on or off."""
|
"""Return if the sensor is on or off."""
|
||||||
|
if self.info.primary_value.value is None:
|
||||||
|
return None
|
||||||
return int(self.info.primary_value.value) == int(self.state_key)
|
return int(self.info.primary_value.value) == int(self.state_key)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -349,8 +353,10 @@ class ZWavePropertyBinarySensor(ZWaveBaseEntity, BinarySensorEntity):
|
|||||||
self._mapping_info = self._get_sensor_mapping()
|
self._mapping_info = self._get_sensor_mapping()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> Optional[bool]:
|
||||||
"""Return if the sensor is on or off."""
|
"""Return if the sensor is on or off."""
|
||||||
|
if self.info.primary_value.value is None:
|
||||||
|
return None
|
||||||
return self.info.primary_value.value in self._mapping_info["on_states"]
|
return self.info.primary_value.value in self._mapping_info["on_states"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user