mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 04:41:30 -04:00
Add laser dirty binary sensor to Litter-Robot 4 (#187128)
This commit is contained in:
@@ -66,6 +66,12 @@ BINARY_SENSOR_MAP: dict[
|
||||
entity_registry_enabled_default=False,
|
||||
is_on_fn=lambda robot: not robot.is_hopper_removed,
|
||||
),
|
||||
RobotBinarySensorEntityDescription[LitterRobot4](
|
||||
key="laser_dirty",
|
||||
translation_key="laser_dirty",
|
||||
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||
is_on_fn=lambda robot: robot.is_laser_dirty,
|
||||
),
|
||||
),
|
||||
LitterRobot5: (
|
||||
RobotBinarySensorEntityDescription[LitterRobot5](
|
||||
|
||||
@@ -11,7 +11,7 @@ from homeassistant.components.binary_sensor import (
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .conftest import setup_integration
|
||||
from .conftest import create_mock_account, setup_integration
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2022-09-18 23:00:44+00:00")
|
||||
@@ -47,6 +47,25 @@ async def test_litterhopper_binary_sensors(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("laser_dirty", "expected_state"),
|
||||
[(False, "off"), (True, "on")],
|
||||
)
|
||||
async def test_litter_robot_4_laser_dirty(
|
||||
hass: HomeAssistant,
|
||||
laser_dirty: bool,
|
||||
expected_state: str,
|
||||
) -> None:
|
||||
"""Tests the Litter-Robot 4 laser dirty binary sensor."""
|
||||
account = create_mock_account(robot_data={"isLaserDirty": laser_dirty}, v4=True)
|
||||
await setup_integration(hass, account, BINARY_SENSOR_DOMAIN)
|
||||
|
||||
state = hass.states.get("binary_sensor.test_laser_dirty")
|
||||
assert state
|
||||
assert state.state == expected_state
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == BinarySensorDeviceClass.PROBLEM
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_litter_robot_5_binary_sensors(
|
||||
hass: HomeAssistant,
|
||||
|
||||
Reference in New Issue
Block a user