Allow None on Renault binary sensors (#65997)
* Enable None on renault binary sensors * Adjust tests Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
d81139377c
commit
486c068111
2 changed files with 5 additions and 6 deletions
|
@ -64,10 +64,9 @@ class RenaultBinarySensor(
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
"""Return true if the binary sensor is on."""
|
"""Return true if the binary sensor is on."""
|
||||||
return (
|
if (data := self._get_data_attr(self.entity_description.on_key)) is None:
|
||||||
self._get_data_attr(self.entity_description.on_key)
|
return None
|
||||||
== self.entity_description.on_value
|
return data == self.entity_description.on_value
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
BINARY_SENSOR_TYPES: tuple[RenaultBinarySensorEntityDescription, ...] = (
|
BINARY_SENSOR_TYPES: tuple[RenaultBinarySensorEntityDescription, ...] = (
|
||||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import STATE_OFF, Platform
|
from homeassistant.const import STATE_UNKNOWN, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
|
@ -63,7 +63,7 @@ async def test_binary_sensor_empty(
|
||||||
|
|
||||||
expected_entities = mock_vehicle[Platform.BINARY_SENSOR]
|
expected_entities = mock_vehicle[Platform.BINARY_SENSOR]
|
||||||
assert len(entity_registry.entities) == len(expected_entities)
|
assert len(entity_registry.entities) == len(expected_entities)
|
||||||
check_entities_no_data(hass, entity_registry, expected_entities, STATE_OFF)
|
check_entities_no_data(hass, entity_registry, expected_entities, STATE_UNKNOWN)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("fixtures_with_invalid_upstream_exception")
|
@pytest.mark.usefixtures("fixtures_with_invalid_upstream_exception")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue