Fix unknown values in onewire (#113731)
* Fix unknown values in onewire * Update testspull/113973/head
parent
6859bae0b1
commit
33678ff5a4
|
@ -143,6 +143,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)
|
||||
|
|
|
@ -204,8 +204,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:
|
||||
|
|
|
@ -155,7 +155,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"},
|
||||
|
@ -165,7 +167,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…
Reference in New Issue