diff --git a/homeassistant/components/roborock/sensor.py b/homeassistant/components/roborock/sensor.py index 8f14b227a9c..7fb60864811 100644 --- a/homeassistant/components/roborock/sensor.py +++ b/homeassistant/components/roborock/sensor.py @@ -76,6 +76,25 @@ CONSUMABLE_SENSORS = [ ), ] +CLEAN_INFORMATION_SENSORS = [ + RoborockSensorDescription( + native_unit_of_measurement=UnitOfTime.SECONDS, + key="cleaning_time", + translation_key="cleaning_time", + icon="mdi:progress-clock", + device_class=SensorDeviceClass.DURATION, + value_fn=lambda data: data.status.clean_time, + ), + RoborockSensorDescription( + native_unit_of_measurement=UnitOfTime.SECONDS, + key="total_cleaning_time", + translation_key="total_cleaning_time", + icon="mdi:history", + device_class=SensorDeviceClass.DURATION, + value_fn=lambda data: data.clean_summary.clean_time, + ), +] + async def async_setup_entry( hass: HomeAssistant, @@ -93,7 +112,7 @@ async def async_setup_entry( description, ) for device_id, coordinator in coordinators.items() - for description in CONSUMABLE_SENSORS + for description in CONSUMABLE_SENSORS + CLEAN_INFORMATION_SENSORS ) diff --git a/homeassistant/components/roborock/strings.json b/homeassistant/components/roborock/strings.json index 7e8e2ba37a0..226adab6cd5 100644 --- a/homeassistant/components/roborock/strings.json +++ b/homeassistant/components/roborock/strings.json @@ -28,6 +28,9 @@ }, "entity": { "sensor": { + "cleaning_time": { + "name": "Cleaning time" + }, "main_brush_time_left": { "name": "Main brush time left" }, @@ -39,6 +42,9 @@ }, "sensor_time_left": { "name": "Sensor time left" + }, + "total_cleaning_time": { + "name": "Total cleaning time" } }, "select": { diff --git a/tests/components/roborock/test_sensor.py b/tests/components/roborock/test_sensor.py index 84443506208..4c774cd6e32 100644 --- a/tests/components/roborock/test_sensor.py +++ b/tests/components/roborock/test_sensor.py @@ -14,7 +14,7 @@ from tests.common import MockConfigEntry async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> None: """Test sensors and check test values are correctly set.""" - assert len(hass.states.async_all("sensor")) == 4 + assert len(hass.states.async_all("sensor")) == 6 assert hass.states.get("sensor.roborock_s7_maxv_main_brush_time_left").state == str( MAIN_BRUSH_REPLACE_TIME - 74382 ) @@ -27,3 +27,7 @@ async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> Non assert hass.states.get("sensor.roborock_s7_maxv_sensor_time_left").state == str( SENSOR_DIRTY_REPLACE_TIME - 74382 ) + assert hass.states.get("sensor.roborock_s7_maxv_cleaning_time").state == "1176" + assert ( + hass.states.get("sensor.roborock_s7_maxv_total_cleaning_time").state == "74382" + )