Add last seen and status code diagnostic sensors to litterrobot (#71760)
This commit is contained in:
parent
3e386064cf
commit
72a65b6a21
4 changed files with 72 additions and 4 deletions
|
@ -17,6 +17,7 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PERCENTAGE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -63,7 +64,9 @@ class LitterRobotSensorEntity(LitterRobotEntity, SensorEntity):
|
|||
def native_value(self) -> StateType | datetime:
|
||||
"""Return the state."""
|
||||
if self.entity_description.should_report(self.robot):
|
||||
return getattr(self.robot, self.entity_description.key)
|
||||
if isinstance(val := getattr(self.robot, self.entity_description.key), str):
|
||||
return val.lower()
|
||||
return val
|
||||
return None
|
||||
|
||||
@property
|
||||
|
@ -93,6 +96,18 @@ ROBOT_SENSORS = [
|
|||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
should_report=lambda robot: robot.sleep_mode_enabled,
|
||||
),
|
||||
LitterRobotSensorEntityDescription(
|
||||
name="Last Seen",
|
||||
key="last_seen",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
LitterRobotSensorEntityDescription(
|
||||
name="Status Code",
|
||||
key="status_code",
|
||||
device_class="litterrobot__status_code",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
28
homeassistant/components/litterrobot/strings.sensor.json
Normal file
28
homeassistant/components/litterrobot/strings.sensor.json
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"state": {
|
||||
"litterrobot__status_code": {
|
||||
"br": "Bonnet Removed",
|
||||
"ccc": "Clean Cycle Complete",
|
||||
"ccp": "Clean Cycle In Progress",
|
||||
"csf": "Cat Sensor Fault",
|
||||
"csi": "Cat Sensor Interrupted",
|
||||
"cst": "Cat Sensor Timing",
|
||||
"df1": "Drawer Almost Full - 2 Cycles Left",
|
||||
"df2": "Drawer Almost Full - 1 Cycle Left",
|
||||
"dfs": "Drawer Full",
|
||||
"dhf": "Dump + Home Position Fault",
|
||||
"dpf": "Dump Position Fault",
|
||||
"ec": "Empty Cycle",
|
||||
"hpf": "Home Position Fault",
|
||||
"off": "[%key:common::state::off%]",
|
||||
"offline": "Offline",
|
||||
"otf": "Over Torque Fault",
|
||||
"p": "[%key:common::state::paused%]",
|
||||
"pd": "Pinch Detect",
|
||||
"rdy": "Ready",
|
||||
"scf": "Cat Sensor Fault At Startup",
|
||||
"sdf": "Drawer Full At Startup",
|
||||
"spf": "Pinch Detect At Startup"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"state": {
|
||||
"litterrobot__status_code": {
|
||||
"br": "Bonnet Removed",
|
||||
"ccc": "Clean Cycle Complete",
|
||||
"ccp": "Clean Cycle In Progress",
|
||||
"csf": "Cat Sensor Fault",
|
||||
"csi": "Cat Sensor Interrupted",
|
||||
"cst": "Cat Sensor Timing",
|
||||
"df1": "Drawer Almost Full - 2 Cycles Left",
|
||||
"df2": "Drawer Almost Full - 1 Cycle Left",
|
||||
"dfs": "Drawer Full",
|
||||
"dhf": "Dump + Home Position Fault",
|
||||
"dpf": "Dump Position Fault",
|
||||
"ec": "Empty Cycle",
|
||||
"hpf": "Home Position Fault",
|
||||
"off": "Off",
|
||||
"offline": "Offline",
|
||||
"otf": "Over Torque Fault",
|
||||
"p": "Paused",
|
||||
"pd": "Pinch Detect",
|
||||
"rdy": "Ready",
|
||||
"scf": "Cat Sensor Fault At Startup",
|
||||
"sdf": "Drawer Full At Startup",
|
||||
"spf": "Pinch Detect At Startup"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -162,11 +162,8 @@ class LitterRobotCleaner(LitterRobotControlEntity, StateVacuumEntity):
|
|||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return device specific state attributes."""
|
||||
return {
|
||||
"clean_cycle_wait_time_minutes": self.robot.clean_cycle_wait_time_minutes,
|
||||
"is_sleeping": self.robot.is_sleeping,
|
||||
"sleep_mode_enabled": self.robot.sleep_mode_enabled,
|
||||
"power_status": self.robot.power_status,
|
||||
"status_code": self.robot.status_code,
|
||||
"last_seen": self.robot.last_seen,
|
||||
"status": self.status,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue