From 7add36d847959d7b962d2c511ec91bcea2d6336c Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Tue, 27 Jun 2023 04:12:02 -0400 Subject: [PATCH] Add entity translations to Litterrobot (#95316) --- .../components/litterrobot/binary_sensor.py | 6 +- .../components/litterrobot/button.py | 4 +- .../components/litterrobot/select.py | 5 +- .../components/litterrobot/sensor.py | 15 ++--- .../components/litterrobot/strings.json | 66 +++++++++++++++++++ .../components/litterrobot/switch.py | 4 +- .../components/litterrobot/update.py | 2 +- .../components/litterrobot/vacuum.py | 4 +- 8 files changed, 86 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/litterrobot/binary_sensor.py b/homeassistant/components/litterrobot/binary_sensor.py index 107935be7b8..5308a3b4f83 100644 --- a/homeassistant/components/litterrobot/binary_sensor.py +++ b/homeassistant/components/litterrobot/binary_sensor.py @@ -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, diff --git a/homeassistant/components/litterrobot/button.py b/homeassistant/components/litterrobot/button.py index 1d208ca48e1..06c4fe75888 100644 --- a/homeassistant/components/litterrobot/button.py +++ b/homeassistant/components/litterrobot/button.py @@ -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(), ) diff --git a/homeassistant/components/litterrobot/select.py b/homeassistant/components/litterrobot/select.py index feac85ecac4..6fabd6ea526 100644 --- a/homeassistant/components/litterrobot/select.py +++ b/homeassistant/components/litterrobot/select.py @@ -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, diff --git a/homeassistant/components/litterrobot/sensor.py b/homeassistant/components/litterrobot/sensor.py index e7aed366fa3..ba601a0ba54 100644 --- a/homeassistant/components/litterrobot/sensor.py +++ b/homeassistant/components/litterrobot/sensor.py @@ -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, diff --git a/homeassistant/components/litterrobot/strings.json b/homeassistant/components/litterrobot/strings.json index b4aa8f0016d..c136cd7f685 100644 --- a/homeassistant/components/litterrobot/strings.json +++ b/homeassistant/components/litterrobot/strings.json @@ -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" + } } } } diff --git a/homeassistant/components/litterrobot/switch.py b/homeassistant/components/litterrobot/switch.py index eb2297e506e..6b4e5b56b48 100644 --- a/homeassistant/components/litterrobot/switch.py +++ b/homeassistant/components/litterrobot/switch.py @@ -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), ), diff --git a/homeassistant/components/litterrobot/update.py b/homeassistant/components/litterrobot/update.py index 33ca6cd0376..9b8391c5bae 100644 --- a/homeassistant/components/litterrobot/update.py +++ b/homeassistant/components/litterrobot/update.py @@ -24,7 +24,7 @@ SCAN_INTERVAL = timedelta(days=1) FIRMWARE_UPDATE_ENTITY = UpdateEntityDescription( key="firmware", - name="Firmware", + translation_key="firmware", device_class=UpdateDeviceClass.FIRMWARE, ) diff --git a/homeassistant/components/litterrobot/vacuum.py b/homeassistant/components/litterrobot/vacuum.py index b56724f15c8..d1352c1e45f 100644 --- a/homeassistant/components/litterrobot/vacuum.py +++ b/homeassistant/components/litterrobot/vacuum.py @@ -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(