mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Add total cleaning count sensor to Roborock (#135015)
This commit is contained in:
parent
3a213b2d17
commit
0dd9845501
@ -61,6 +61,9 @@
|
|||||||
"total_cleaning_area": {
|
"total_cleaning_area": {
|
||||||
"default": "mdi:texture-box"
|
"default": "mdi:texture-box"
|
||||||
},
|
},
|
||||||
|
"total_cleaning_count": {
|
||||||
|
"default": "mdi:counter"
|
||||||
|
},
|
||||||
"vacuum_error": {
|
"vacuum_error": {
|
||||||
"default": "mdi:alert-circle"
|
"default": "mdi:alert-circle"
|
||||||
},
|
},
|
||||||
|
@ -24,6 +24,7 @@ from homeassistant.components.sensor import (
|
|||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import PERCENTAGE, EntityCategory, UnitOfArea, UnitOfTime
|
from homeassistant.const import PERCENTAGE, EntityCategory, UnitOfArea, UnitOfTime
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -112,6 +113,13 @@ SENSOR_DESCRIPTIONS = [
|
|||||||
value_fn=lambda data: data.clean_summary.clean_time,
|
value_fn=lambda data: data.clean_summary.clean_time,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
|
RoborockSensorDescription(
|
||||||
|
key="total_cleaning_count",
|
||||||
|
translation_key="total_cleaning_count",
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
|
value_fn=lambda data: data.clean_summary.clean_count,
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
),
|
||||||
RoborockSensorDescription(
|
RoborockSensorDescription(
|
||||||
key="status",
|
key="status",
|
||||||
device_class=SensorDeviceClass.ENUM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
@ -228,6 +228,9 @@
|
|||||||
"total_cleaning_area": {
|
"total_cleaning_area": {
|
||||||
"name": "Total cleaning area"
|
"name": "Total cleaning area"
|
||||||
},
|
},
|
||||||
|
"total_cleaning_count": {
|
||||||
|
"name": "Total cleaning count"
|
||||||
|
},
|
||||||
"vacuum_error": {
|
"vacuum_error": {
|
||||||
"name": "Vacuum error",
|
"name": "Vacuum error",
|
||||||
"state": {
|
"state": {
|
||||||
|
@ -29,7 +29,7 @@ def platforms() -> list[Platform]:
|
|||||||
|
|
||||||
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")) == 38
|
assert len(hass.states.async_all("sensor")) == 40
|
||||||
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
|
||||||
)
|
)
|
||||||
@ -54,6 +54,7 @@ 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_total_cleaning_count").state == "31"
|
||||||
assert (
|
assert (
|
||||||
hass.states.get("sensor.roborock_s7_maxv_last_clean_begin").state
|
hass.states.get("sensor.roborock_s7_maxv_last_clean_begin").state
|
||||||
== "2023-01-01T03:22:10+00:00"
|
== "2023-01-01T03:22:10+00:00"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user