mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add more information to Roborock Status (#93636)
Co-authored-by: Humberto Gontijo <humberto.gontijo@clevertech.biz>
This commit is contained in:
parent
8e05e3850b
commit
de3406c856
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
|
||||
from roborock.containers import RoborockStateCode
|
||||
from roborock.roborock_typing import DeviceProp
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
@ -37,7 +38,7 @@ class RoborockSensorDescription(
|
||||
"""A class that describes Roborock sensors."""
|
||||
|
||||
|
||||
CONSUMABLE_SENSORS = [
|
||||
SENSOR_DESCRIPTIONS = [
|
||||
RoborockSensorDescription(
|
||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||
key="main_brush_time_left",
|
||||
@ -74,9 +75,6 @@ CONSUMABLE_SENSORS = [
|
||||
value_fn=lambda data: data.consumable.sensor_time_left,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
]
|
||||
|
||||
CLEAN_INFORMATION_SENSORS = [
|
||||
RoborockSensorDescription(
|
||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||
key="cleaning_time",
|
||||
@ -92,6 +90,15 @@ CLEAN_INFORMATION_SENSORS = [
|
||||
device_class=SensorDeviceClass.DURATION,
|
||||
value_fn=lambda data: data.clean_summary.clean_time,
|
||||
),
|
||||
RoborockSensorDescription(
|
||||
key="status",
|
||||
icon="mdi:information-outline",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
translation_key="status",
|
||||
value_fn=lambda data: data.status.state.name,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
options=RoborockStateCode.keys(),
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@ -111,7 +118,7 @@ async def async_setup_entry(
|
||||
description,
|
||||
)
|
||||
for device_id, coordinator in coordinators.items()
|
||||
for description in CONSUMABLE_SENSORS + CLEAN_INFORMATION_SENSORS
|
||||
for description in SENSOR_DESCRIPTIONS
|
||||
)
|
||||
|
||||
|
||||
|
@ -43,6 +43,34 @@
|
||||
"sensor_time_left": {
|
||||
"name": "Sensor time left"
|
||||
},
|
||||
"status": {
|
||||
"name": "Status",
|
||||
"state": {
|
||||
"starting": "Starting",
|
||||
"charger_disconnected": "Charger disconnected",
|
||||
"idle": "Idle",
|
||||
"remote_control_active": "Remote control active",
|
||||
"cleaning": "Cleaning",
|
||||
"returning_home": "Returning home",
|
||||
"manual_mode": "Manual mode",
|
||||
"charging": "Charging",
|
||||
"charging_problem": "Charging problem",
|
||||
"paused": "Paused",
|
||||
"spot_cleaning": "Spot cleaning",
|
||||
"error": "Error",
|
||||
"shutting_down": "Shutting down",
|
||||
"updating": "Updating",
|
||||
"docking": "Docking",
|
||||
"going_to_target": "Going to target",
|
||||
"zoned_cleaning": "Zoned cleaning",
|
||||
"segment_cleaning": "Segment cleaning",
|
||||
"emptying_the_bin": "Emptying the bin",
|
||||
"washing_the_mop": "Washing the mop",
|
||||
"going_to_wash_the_mop": "Going to wash the mop",
|
||||
"charging_complete": "Charging complete",
|
||||
"device_offline": "Device offline"
|
||||
}
|
||||
},
|
||||
"total_cleaning_time": {
|
||||
"name": "Total cleaning time"
|
||||
}
|
||||
|
@ -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")) == 6
|
||||
assert len(hass.states.async_all("sensor")) == 7
|
||||
assert hass.states.get("sensor.roborock_s7_maxv_main_brush_time_left").state == str(
|
||||
MAIN_BRUSH_REPLACE_TIME - 74382
|
||||
)
|
||||
@ -31,3 +31,4 @@ async def test_sensors(hass: HomeAssistant, setup_entry: MockConfigEntry) -> Non
|
||||
assert (
|
||||
hass.states.get("sensor.roborock_s7_maxv_total_cleaning_time").state == "74382"
|
||||
)
|
||||
assert hass.states.get("sensor.roborock_s7_maxv_status").state == "charging"
|
||||
|
Loading…
x
Reference in New Issue
Block a user