Use enum sensor device class in Litter-Robot (#83290)

This commit is contained in:
Franck Nijhof 2022-12-06 11:08:05 +01:00 committed by GitHub
parent d62bdbb9ff
commit c25ba19ffd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 96 additions and 33 deletions

View file

@ -97,8 +97,36 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
RobotSensorEntityDescription[LitterRobot](
key="status_code",
name="Status Code",
device_class="litterrobot__status_code",
translation_key="status_code",
entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.ENUM,
options=[
"br",
"ccc",
"ccp",
"cd",
"csf",
"csi",
"cst",
"df1",
"df2",
"dfs",
"dhf",
"dpf",
"ec",
"hpf",
"off",
"offline",
"otf",
"p",
"pd",
"pwrd",
"pwru",
"rdy",
"scf",
"sdf",
"spf",
],
),
],
LitterRobot4: [

View file

@ -30,5 +30,38 @@
"title": "Litter-Robot attributes are now their own sensors",
"description": "The vacuum entity attributes are now available as diagnostic sensors.\n\nPlease adjust any automations or scripts you may have that use these attributes."
}
},
"entity": {
"sensor": {
"status_code": {
"state": {
"br": "Bonnet Removed",
"ccc": "Clean Cycle Complete",
"ccp": "Clean Cycle In Progress",
"cd": "Cat Detected",
"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",
"pwrd": "Powering Down",
"pwru": "Powering Up",
"rdy": "Ready",
"scf": "Cat Sensor Fault At Startup",
"sdf": "Drawer Full At Startup",
"spf": "Pinch Detect At Startup"
}
}
}
}
}

View file

@ -1,31 +0,0 @@
{
"state": {
"litterrobot__status_code": {
"br": "Bonnet Removed",
"ccc": "Clean Cycle Complete",
"ccp": "Clean Cycle In Progress",
"cd": "Cat Detected",
"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",
"pwrd": "Powering Down",
"pwru": "Powering Up",
"rdy": "Ready",
"scf": "Cat Sensor Fault At Startup",
"sdf": "Drawer Full At Startup",
"spf": "Pinch Detect At Startup"
}
}
}

View file

@ -25,6 +25,39 @@
}
}
},
"entity": {
"sensor": {
"status_code": {
"state": {
"br": "Bonnet Removed",
"ccc": "Clean Cycle Complete",
"ccp": "Clean Cycle In Progress",
"cd": "Cat Detected",
"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",
"pwrd": "Powering Down",
"pwru": "Powering Up",
"rdy": "Ready",
"scf": "Cat Sensor Fault At Startup",
"sdf": "Drawer Full At Startup",
"spf": "Pinch Detect At Startup"
}
}
}
},
"issues": {
"migrated_attributes": {
"description": "The vacuum entity attributes are now available as diagnostic sensors.\n\nPlease adjust any automations or scripts you may have that use these attributes.",

View file

@ -86,7 +86,7 @@ async def test_litter_robot_sensor(
assert sensor.attributes["device_class"] == SensorDeviceClass.TIMESTAMP
sensor = hass.states.get("sensor.test_status_code")
assert sensor.state == "dfs"
assert sensor.attributes["device_class"] == "litterrobot__status_code"
assert sensor.attributes["device_class"] == SensorDeviceClass.ENUM
sensor = hass.states.get("sensor.test_litter_level")
assert sensor.state == "70.0"
assert sensor.attributes["unit_of_measurement"] == PERCENTAGE