mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Fix unknown values in onewire (#113731)
* Fix unknown values in onewire * Update tests
This commit is contained in:
parent
20897e0a3a
commit
3844ade572
@ -144,6 +144,8 @@ class OneWireBinarySensor(OneWireEntity, BinarySensorEntity):
|
||||
entity_description: OneWireBinarySensorEntityDescription
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
def is_on(self) -> bool | None:
|
||||
"""Return true if sensor is on."""
|
||||
if self._state is None:
|
||||
return None
|
||||
return bool(self._state)
|
||||
|
@ -208,8 +208,10 @@ class OneWireSwitch(OneWireEntity, SwitchEntity):
|
||||
entity_description: OneWireSwitchEntityDescription
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if sensor is on."""
|
||||
def is_on(self) -> bool | None:
|
||||
"""Return true if switch is on."""
|
||||
if self._state is None:
|
||||
return None
|
||||
return bool(self._state)
|
||||
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
|
@ -156,7 +156,9 @@ MOCK_OWPROXY_DEVICES = {
|
||||
{ATTR_INJECT_READS: b" 1"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{
|
||||
ATTR_INJECT_READS: ProtocolError,
|
||||
},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
@ -166,7 +168,9 @@ MOCK_OWPROXY_DEVICES = {
|
||||
{ATTR_INJECT_READS: b" 1"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{ATTR_INJECT_READS: b" 1"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{
|
||||
ATTR_INJECT_READS: ProtocolError,
|
||||
},
|
||||
{ATTR_INJECT_READS: b" 1"},
|
||||
{ATTR_INJECT_READS: b" 0"},
|
||||
{ATTR_INJECT_READS: b" 1"},
|
||||
|
@ -851,13 +851,13 @@
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_file': '/29.111111111111/sensed.3',
|
||||
'friendly_name': '29.111111111111 Sensed 3',
|
||||
'raw_value': 0.0,
|
||||
'raw_value': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.29_111111111111_sensed_3',
|
||||
'last_changed': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
'state': 'unknown',
|
||||
}),
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
|
@ -1271,13 +1271,13 @@
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_file': '/29.111111111111/PIO.3',
|
||||
'friendly_name': '29.111111111111 Programmed input-output 3',
|
||||
'raw_value': 0.0,
|
||||
'raw_value': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.29_111111111111_programmed_input_output_3',
|
||||
'last_changed': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
'state': 'unknown',
|
||||
}),
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
|
Loading…
x
Reference in New Issue
Block a user