From dd111416e746c6d3c8f1ec13fa5e1023660de919 Mon Sep 17 00:00:00 2001 From: Luke Lashley Date: Wed, 25 Oct 2023 00:10:31 -0400 Subject: [PATCH] Add cleaning binary sensor to Roborock (#102748) --- homeassistant/components/roborock/binary_sensor.py | 8 ++++++++ homeassistant/components/roborock/strings.json | 3 +++ tests/components/roborock/test_binary_sensor.py | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/roborock/binary_sensor.py b/homeassistant/components/roborock/binary_sensor.py index 320b0fc7c6d..a8f6a6fbb4f 100644 --- a/homeassistant/components/roborock/binary_sensor.py +++ b/homeassistant/components/roborock/binary_sensor.py @@ -69,6 +69,14 @@ BINARY_SENSOR_DESCRIPTIONS = [ entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda data: data.status.water_shortage_status, ), + RoborockBinarySensorDescription( + key="in_cleaning", + translation_key="in_cleaning", + icon="mdi:vacuum", + device_class=BinarySensorDeviceClass.RUNNING, + entity_category=EntityCategory.DIAGNOSTIC, + value_fn=lambda data: data.status.in_cleaning, + ), ] diff --git a/homeassistant/components/roborock/strings.json b/homeassistant/components/roborock/strings.json index 87d06f92f46..06cffcc2291 100644 --- a/homeassistant/components/roborock/strings.json +++ b/homeassistant/components/roborock/strings.json @@ -28,6 +28,9 @@ }, "entity": { "binary_sensor": { + "in_cleaning": { + "name": "Cleaning" + }, "mop_attached": { "name": "Mop attached" }, diff --git a/tests/components/roborock/test_binary_sensor.py b/tests/components/roborock/test_binary_sensor.py index 4edf8ff4710..e70dac5ffc9 100644 --- a/tests/components/roborock/test_binary_sensor.py +++ b/tests/components/roborock/test_binary_sensor.py @@ -9,7 +9,7 @@ async def test_binary_sensors( hass: HomeAssistant, setup_entry: MockConfigEntry ) -> None: """Test binary sensors and check test values are correctly set.""" - assert len(hass.states.async_all("binary_sensor")) == 6 + assert len(hass.states.async_all("binary_sensor")) == 8 assert hass.states.get("binary_sensor.roborock_s7_maxv_mop_attached").state == "on" assert ( hass.states.get("binary_sensor.roborock_s7_maxv_water_box_attached").state @@ -18,3 +18,4 @@ async def test_binary_sensors( assert ( hass.states.get("binary_sensor.roborock_s7_maxv_water_shortage").state == "off" ) + assert hass.states.get("binary_sensor.roborock_s7_maxv_cleaning").state == "off"