diff --git a/homeassistant/components/litterrobot/icons.json b/homeassistant/components/litterrobot/icons.json index 163ad80c0a8..2e0cafe43d9 100644 --- a/homeassistant/components/litterrobot/icons.json +++ b/homeassistant/components/litterrobot/icons.json @@ -46,6 +46,9 @@ "motor_fault_short": "mdi:flash-off", "motor_ot_amps": "mdi:flash-alert" } + }, + "total_cycles": { + "default": "mdi:counter" } }, "switch": { diff --git a/homeassistant/components/litterrobot/sensor.py b/homeassistant/components/litterrobot/sensor.py index cdd9a1c08a5..b7ddf3c3249 100644 --- a/homeassistant/components/litterrobot/sensor.py +++ b/homeassistant/components/litterrobot/sensor.py @@ -115,6 +115,14 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = { lambda robot: status.lower() if (status := robot.status_code) else None ), ), + RobotSensorEntityDescription[LitterRobot]( + key="total_cycles", + translation_key="total_cycles", + entity_category=EntityCategory.DIAGNOSTIC, + entity_registry_enabled_default=False, + state_class=SensorStateClass.TOTAL_INCREASING, + value_fn=lambda robot: robot.cycle_count, + ), ], LitterRobot4: [ RobotSensorEntityDescription[LitterRobot4]( diff --git a/homeassistant/components/litterrobot/strings.json b/homeassistant/components/litterrobot/strings.json index ba5472918d3..d9931d71a0d 100644 --- a/homeassistant/components/litterrobot/strings.json +++ b/homeassistant/components/litterrobot/strings.json @@ -118,6 +118,10 @@ "spf": "Pinch detect at startup" } }, + "total_cycles": { + "name": "Total cycles", + "unit_of_measurement": "cycles" + }, "waste_drawer": { "name": "Waste drawer" } diff --git a/tests/components/litterrobot/test_sensor.py b/tests/components/litterrobot/test_sensor.py index bbc6274e56b..76c567f5417 100644 --- a/tests/components/litterrobot/test_sensor.py +++ b/tests/components/litterrobot/test_sensor.py @@ -5,7 +5,11 @@ from unittest.mock import MagicMock import pytest from homeassistant.components.litterrobot.sensor import icon_for_gauge_level -from homeassistant.components.sensor import DOMAIN as PLATFORM_DOMAIN, SensorDeviceClass +from homeassistant.components.sensor import ( + DOMAIN as PLATFORM_DOMAIN, + SensorDeviceClass, + SensorStateClass, +) from homeassistant.const import PERCENTAGE, STATE_UNKNOWN, UnitOfMass from homeassistant.core import HomeAssistant @@ -70,6 +74,7 @@ async def test_gauge_icon() -> None: @pytest.mark.freeze_time("2022-09-18 23:00:44+00:00") +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_litter_robot_sensor( hass: HomeAssistant, mock_account_with_litterrobot_4: MagicMock ) -> None: @@ -94,6 +99,9 @@ async def test_litter_robot_sensor( sensor = hass.states.get("sensor.test_pet_weight") assert sensor.state == "12.0" assert sensor.attributes["unit_of_measurement"] == UnitOfMass.POUNDS + sensor = hass.states.get("sensor.test_total_cycles") + assert sensor.state == "158" + assert sensor.attributes["state_class"] == SensorStateClass.TOTAL_INCREASING async def test_feeder_robot_sensor(