mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add new sensors to Roborock (#99983)
* Add 3 new sensor types * add state options for dock error * add unit of measurement
This commit is contained in:
parent
092580a3ed
commit
602e36aa12
@ -4,7 +4,12 @@ from __future__ import annotations
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
|
||||
from roborock.containers import RoborockErrorCode, RoborockStateCode
|
||||
from roborock.containers import (
|
||||
RoborockDockErrorCode,
|
||||
RoborockDockTypeCode,
|
||||
RoborockErrorCode,
|
||||
RoborockStateCode,
|
||||
)
|
||||
from roborock.roborock_typing import DeviceProp
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
@ -134,6 +139,35 @@ SENSOR_DESCRIPTIONS = [
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
),
|
||||
# Only available on some newer models
|
||||
RoborockSensorDescription(
|
||||
key="clean_percent",
|
||||
icon="mdi:progress-check",
|
||||
translation_key="clean_percent",
|
||||
value_fn=lambda data: data.status.clean_percent,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
),
|
||||
# Only available with more than just the basic dock
|
||||
RoborockSensorDescription(
|
||||
key="dock_error",
|
||||
icon="mdi:garage-open",
|
||||
translation_key="dock_error",
|
||||
value_fn=lambda data: data.status.dock_error_status.name
|
||||
if data.status.dock_type != RoborockDockTypeCode.no_dock
|
||||
else None,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=RoborockDockErrorCode.keys(),
|
||||
),
|
||||
RoborockSensorDescription(
|
||||
key="mop_clean_remaining",
|
||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||
device_class=SensorDeviceClass.DURATION,
|
||||
value_fn=lambda data: data.status.rdt,
|
||||
translation_key="mop_drying_remaining_time",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
@ -50,9 +50,26 @@
|
||||
"cleaning_time": {
|
||||
"name": "Cleaning time"
|
||||
},
|
||||
"clean_percent": {
|
||||
"name": "Cleaning progress"
|
||||
},
|
||||
"dock_error": {
|
||||
"name": "Dock error",
|
||||
"state": {
|
||||
"ok": "Ok",
|
||||
"duct_blockage": "Duct blockage",
|
||||
"water_empty": "Water empty",
|
||||
"waste_water_tank_full": "Waste water tank full",
|
||||
"dirty_tank_latch_open": "Dirty tank latch open",
|
||||
"no_dustbin": "No dustbin"
|
||||
}
|
||||
},
|
||||
"main_brush_time_left": {
|
||||
"name": "Main brush time left"
|
||||
},
|
||||
"mop_drying_remaining_time": {
|
||||
"name": "Mop drying remaining time"
|
||||
},
|
||||
"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:
|
||||
"""Test sensors and check test values are correctly set."""
|
||||
assert len(hass.states.async_all("sensor")) == 11
|
||||
assert len(hass.states.async_all("sensor")) == 12
|
||||
assert hass.states.get("sensor.roborock_s7_maxv_main_brush_time_left").state == str(
|
||||
MAIN_BRUSH_REPLACE_TIME - 74382
|
||||
)
|
||||
@ -38,3 +38,4 @@ async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> Non
|
||||
assert hass.states.get("sensor.roborock_s7_maxv_cleaning_area").state == "21.0"
|
||||
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_dock_error").state == "ok"
|
||||
|
Loading…
x
Reference in New Issue
Block a user