diff --git a/homeassistant/components/litterrobot/binary_sensor.py b/homeassistant/components/litterrobot/binary_sensor.py index aedd24e5ba00..c943a7034237 100644 --- a/homeassistant/components/litterrobot/binary_sensor.py +++ b/homeassistant/components/litterrobot/binary_sensor.py @@ -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]( diff --git a/tests/components/litterrobot/test_binary_sensor.py b/tests/components/litterrobot/test_binary_sensor.py index b0fba179e425..bee5a4000c57 100644 --- a/tests/components/litterrobot/test_binary_sensor.py +++ b/tests/components/litterrobot/test_binary_sensor.py @@ -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,