Add last clean sensors to Roborock (#100661)
* Add water shortage binary sensor * add last clean sensors * fix tests * fix tests again * remove accidentally added binary sensor
This commit is contained in:
parent
6e0ab35f85
commit
e2bfa9f9cd
3 changed files with 31 additions and 1 deletions
|
@ -143,6 +143,22 @@ SENSOR_DESCRIPTIONS = [
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
),
|
),
|
||||||
|
RoborockSensorDescription(
|
||||||
|
key="last_clean_start",
|
||||||
|
translation_key="last_clean_start",
|
||||||
|
icon="mdi:clock-time-twelve",
|
||||||
|
value_fn=lambda data: data.last_clean_record.begin_datetime,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
|
),
|
||||||
|
RoborockSensorDescription(
|
||||||
|
key="last_clean_end",
|
||||||
|
translation_key="last_clean_end",
|
||||||
|
icon="mdi:clock-time-twelve",
|
||||||
|
value_fn=lambda data: data.last_clean_record.end_datetime,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
|
),
|
||||||
# Only available on some newer models
|
# Only available on some newer models
|
||||||
RoborockSensorDescription(
|
RoborockSensorDescription(
|
||||||
key="clean_percent",
|
key="clean_percent",
|
||||||
|
|
|
@ -73,6 +73,12 @@
|
||||||
"mop_drying_remaining_time": {
|
"mop_drying_remaining_time": {
|
||||||
"name": "Mop drying remaining time"
|
"name": "Mop drying remaining time"
|
||||||
},
|
},
|
||||||
|
"last_clean_start": {
|
||||||
|
"name": "Last clean begin"
|
||||||
|
},
|
||||||
|
"last_clean_end": {
|
||||||
|
"name": "Last clean end"
|
||||||
|
},
|
||||||
"side_brush_time_left": {
|
"side_brush_time_left": {
|
||||||
"name": "Side brush time left"
|
"name": "Side brush time left"
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,7 +14,7 @@ from tests.common import MockConfigEntry
|
||||||
|
|
||||||
async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> None:
|
async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> None:
|
||||||
"""Test sensors and check test values are correctly set."""
|
"""Test sensors and check test values are correctly set."""
|
||||||
assert len(hass.states.async_all("sensor")) == 24
|
assert len(hass.states.async_all("sensor")) == 28
|
||||||
assert hass.states.get("sensor.roborock_s7_maxv_main_brush_time_left").state == str(
|
assert hass.states.get("sensor.roborock_s7_maxv_main_brush_time_left").state == str(
|
||||||
MAIN_BRUSH_REPLACE_TIME - 74382
|
MAIN_BRUSH_REPLACE_TIME - 74382
|
||||||
)
|
)
|
||||||
|
@ -39,3 +39,11 @@ async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> Non
|
||||||
assert hass.states.get("sensor.roborock_s7_maxv_vacuum_error").state == "none"
|
assert hass.states.get("sensor.roborock_s7_maxv_vacuum_error").state == "none"
|
||||||
assert hass.states.get("sensor.roborock_s7_maxv_battery").state == "100"
|
assert hass.states.get("sensor.roborock_s7_maxv_battery").state == "100"
|
||||||
assert hass.states.get("sensor.roborock_s7_maxv_dock_error").state == "ok"
|
assert hass.states.get("sensor.roborock_s7_maxv_dock_error").state == "ok"
|
||||||
|
assert (
|
||||||
|
hass.states.get("sensor.roborock_s7_maxv_last_clean_begin").state
|
||||||
|
== "2023-01-01T03:22:10+00:00"
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
hass.states.get("sensor.roborock_s7_maxv_last_clean_end").state
|
||||||
|
== "2023-01-01T03:43:58+00:00"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue