Add entity translations to Litterrobot (#95316)
This commit is contained in:
parent
c3d02d68b7
commit
7add36d847
8 changed files with 86 additions and 20 deletions
|
@ -51,7 +51,7 @@ BINARY_SENSOR_MAP: dict[type[Robot], tuple[RobotBinarySensorEntityDescription, .
|
|||
LitterRobot: (
|
||||
RobotBinarySensorEntityDescription[LitterRobot](
|
||||
key="sleeping",
|
||||
name="Sleeping",
|
||||
translation_key="sleeping",
|
||||
icon="mdi:sleep",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
|
@ -59,7 +59,7 @@ BINARY_SENSOR_MAP: dict[type[Robot], tuple[RobotBinarySensorEntityDescription, .
|
|||
),
|
||||
RobotBinarySensorEntityDescription[LitterRobot](
|
||||
key="sleep_mode",
|
||||
name="Sleep mode",
|
||||
translation_key="sleep_mode",
|
||||
icon="mdi:sleep",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
|
@ -69,7 +69,7 @@ BINARY_SENSOR_MAP: dict[type[Robot], tuple[RobotBinarySensorEntityDescription, .
|
|||
Robot: (
|
||||
RobotBinarySensorEntityDescription[Robot](
|
||||
key="power_status",
|
||||
name="Power status",
|
||||
translation_key="power_status",
|
||||
device_class=BinarySensorDeviceClass.PLUG,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
|
|
|
@ -60,14 +60,14 @@ class RobotButtonEntityDescription(ButtonEntityDescription, RequiredKeysMixin[_R
|
|||
|
||||
LITTER_ROBOT_BUTTON = RobotButtonEntityDescription[LitterRobot3](
|
||||
key="reset_waste_drawer",
|
||||
name="Reset waste drawer",
|
||||
translation_key="reset_waste_drawer",
|
||||
icon="mdi:delete-variant",
|
||||
entity_category=EntityCategory.CONFIG,
|
||||
press_fn=lambda robot: robot.reset_waste_drawer(),
|
||||
)
|
||||
FEEDER_ROBOT_BUTTON = RobotButtonEntityDescription[FeederRobot](
|
||||
key="give_snack",
|
||||
name="Give snack",
|
||||
translation_key="give_snack",
|
||||
icon="mdi:candy-outline",
|
||||
press_fn=lambda robot: robot.give_snack(),
|
||||
)
|
||||
|
|
|
@ -50,7 +50,7 @@ class RobotSelectEntityDescription(
|
|||
ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
|
||||
LitterRobot: RobotSelectEntityDescription[LitterRobot, int](
|
||||
key="cycle_delay",
|
||||
name="Clean cycle wait time minutes",
|
||||
translation_key="cycle_delay",
|
||||
icon="mdi:timer-outline",
|
||||
unit_of_measurement=UnitOfTime.MINUTES,
|
||||
current_fn=lambda robot: robot.clean_cycle_wait_time_minutes,
|
||||
|
@ -59,7 +59,6 @@ ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
|
|||
),
|
||||
LitterRobot4: RobotSelectEntityDescription[LitterRobot4, str](
|
||||
key="panel_brightness",
|
||||
name="Panel brightness",
|
||||
translation_key="brightness_level",
|
||||
current_fn=lambda robot: bri.name.lower()
|
||||
if (bri := robot.panel_brightness) is not None
|
||||
|
@ -72,7 +71,7 @@ ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
|
|||
),
|
||||
FeederRobot: RobotSelectEntityDescription[FeederRobot, float](
|
||||
key="meal_insert_size",
|
||||
name="Meal insert size",
|
||||
translation_key="meal_insert_size",
|
||||
icon="mdi:scale",
|
||||
unit_of_measurement="cups",
|
||||
current_fn=lambda robot: robot.meal_insert_size,
|
||||
|
|
|
@ -69,32 +69,31 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
|
|||
LitterRobot: [
|
||||
RobotSensorEntityDescription[LitterRobot](
|
||||
key="waste_drawer_level",
|
||||
name="Waste drawer",
|
||||
translation_key="waste_drawer",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon_fn=lambda state: icon_for_gauge_level(state, 10),
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
RobotSensorEntityDescription[LitterRobot](
|
||||
key="sleep_mode_start_time",
|
||||
name="Sleep mode start time",
|
||||
translation_key="sleep_mode_start_time",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
should_report=lambda robot: robot.sleep_mode_enabled,
|
||||
),
|
||||
RobotSensorEntityDescription[LitterRobot](
|
||||
key="sleep_mode_end_time",
|
||||
name="Sleep mode end time",
|
||||
translation_key="sleep_mode_end_time",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
should_report=lambda robot: robot.sleep_mode_enabled,
|
||||
),
|
||||
RobotSensorEntityDescription[LitterRobot](
|
||||
key="last_seen",
|
||||
name="Last seen",
|
||||
translation_key="last_seen",
|
||||
device_class=SensorDeviceClass.TIMESTAMP,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
RobotSensorEntityDescription[LitterRobot](
|
||||
key="status_code",
|
||||
name="Status code",
|
||||
translation_key="status_code",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
|
@ -130,14 +129,14 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
|
|||
LitterRobot4: [
|
||||
RobotSensorEntityDescription[LitterRobot4](
|
||||
key="litter_level",
|
||||
name="Litter level",
|
||||
translation_key="litter_level",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon_fn=lambda state: icon_for_gauge_level(state, 10),
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
RobotSensorEntityDescription[LitterRobot4](
|
||||
key="pet_weight",
|
||||
name="Pet weight",
|
||||
translation_key="pet_weight",
|
||||
native_unit_of_measurement=UnitOfMass.POUNDS,
|
||||
device_class=SensorDeviceClass.WEIGHT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -146,7 +145,7 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
|
|||
FeederRobot: [
|
||||
RobotSensorEntityDescription[FeederRobot](
|
||||
key="food_level",
|
||||
name="Food level",
|
||||
translation_key="food_level",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
icon_fn=lambda state: icon_for_gauge_level(state, 10),
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
|
|
@ -32,8 +32,46 @@
|
|||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"sleeping": {
|
||||
"name": "Sleeping"
|
||||
},
|
||||
"sleep_mode": {
|
||||
"name": "Sleep mode"
|
||||
},
|
||||
"power_status": {
|
||||
"name": "Power status"
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
"reset_waste_drawer": {
|
||||
"name": "Reset waste drawer"
|
||||
},
|
||||
"give_snack": {
|
||||
"name": "Give snack"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"food_level": {
|
||||
"name": "Food level"
|
||||
},
|
||||
"last_seen": {
|
||||
"name": "Last seen"
|
||||
},
|
||||
"litter_level": {
|
||||
"name": "litter level"
|
||||
},
|
||||
"pet_weight": {
|
||||
"name": "Pet weight"
|
||||
},
|
||||
"sleep_mode_end_time": {
|
||||
"name": "Sleep mode end time"
|
||||
},
|
||||
"sleep_mode_start_time": {
|
||||
"name": "Sleep mode start time"
|
||||
},
|
||||
"status_code": {
|
||||
"name": "Status code",
|
||||
"state": {
|
||||
"br": "Bonnet Removed",
|
||||
"ccc": "Clean Cycle Complete",
|
||||
|
@ -61,16 +99,44 @@
|
|||
"sdf": "Drawer Full At Startup",
|
||||
"spf": "Pinch Detect At Startup"
|
||||
}
|
||||
},
|
||||
"waste_drawer": {
|
||||
"name": "Waste drawer"
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
"cycle_delay": {
|
||||
"name": "Clean cycle wait time minutes"
|
||||
},
|
||||
"meal_insert_size": {
|
||||
"name": "Meal insert size"
|
||||
},
|
||||
"brightness_level": {
|
||||
"name": "Panel brightness",
|
||||
"state": {
|
||||
"low": "Low",
|
||||
"medium": "Medium",
|
||||
"high": "High"
|
||||
}
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"night_light_mode": {
|
||||
"name": "Night light mode"
|
||||
},
|
||||
"panel_lockout": {
|
||||
"name": "Panel lockout"
|
||||
}
|
||||
},
|
||||
"vacuum": {
|
||||
"litter_box": {
|
||||
"name": "Litter box"
|
||||
}
|
||||
},
|
||||
"update": {
|
||||
"firmware": {
|
||||
"name": "Firmware"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ class RobotSwitchEntityDescription(SwitchEntityDescription, RequiredKeysMixin[_R
|
|||
ROBOT_SWITCHES = [
|
||||
RobotSwitchEntityDescription[LitterRobot | FeederRobot](
|
||||
key="night_light_mode_enabled",
|
||||
name="Night light mode",
|
||||
translation_key="night_light_mode",
|
||||
icons=("mdi:lightbulb-on", "mdi:lightbulb-off"),
|
||||
set_fn=lambda robot, value: robot.set_night_light(value),
|
||||
),
|
||||
RobotSwitchEntityDescription[LitterRobot | FeederRobot](
|
||||
key="panel_lock_enabled",
|
||||
name="Panel lockout",
|
||||
translation_key="panel_lockout",
|
||||
icons=("mdi:lock", "mdi:lock-open"),
|
||||
set_fn=lambda robot, value: robot.set_panel_lockout(value),
|
||||
),
|
||||
|
|
|
@ -24,7 +24,7 @@ SCAN_INTERVAL = timedelta(days=1)
|
|||
|
||||
FIRMWARE_UPDATE_ENTITY = UpdateEntityDescription(
|
||||
key="firmware",
|
||||
name="Firmware",
|
||||
translation_key="firmware",
|
||||
device_class=UpdateDeviceClass.FIRMWARE,
|
||||
)
|
||||
|
||||
|
|
|
@ -42,7 +42,9 @@ LITTER_BOX_STATUS_STATE_MAP = {
|
|||
LitterBoxStatus.OFF: STATE_OFF,
|
||||
}
|
||||
|
||||
LITTER_BOX_ENTITY = StateVacuumEntityDescription("litter_box", name="Litter box")
|
||||
LITTER_BOX_ENTITY = StateVacuumEntityDescription(
|
||||
"litter_box", translation_key="litter_box"
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue