Add entity translations to Litterrobot (#95316)

This commit is contained in:
Robert Hillis 2023-06-27 04:12:02 -04:00 committed by GitHub
parent c3d02d68b7
commit 7add36d847
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 86 additions and 20 deletions

View file

@ -51,7 +51,7 @@ BINARY_SENSOR_MAP: dict[type[Robot], tuple[RobotBinarySensorEntityDescription, .
LitterRobot: ( LitterRobot: (
RobotBinarySensorEntityDescription[LitterRobot]( RobotBinarySensorEntityDescription[LitterRobot](
key="sleeping", key="sleeping",
name="Sleeping", translation_key="sleeping",
icon="mdi:sleep", icon="mdi:sleep",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -59,7 +59,7 @@ BINARY_SENSOR_MAP: dict[type[Robot], tuple[RobotBinarySensorEntityDescription, .
), ),
RobotBinarySensorEntityDescription[LitterRobot]( RobotBinarySensorEntityDescription[LitterRobot](
key="sleep_mode", key="sleep_mode",
name="Sleep mode", translation_key="sleep_mode",
icon="mdi:sleep", icon="mdi:sleep",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -69,7 +69,7 @@ BINARY_SENSOR_MAP: dict[type[Robot], tuple[RobotBinarySensorEntityDescription, .
Robot: ( Robot: (
RobotBinarySensorEntityDescription[Robot]( RobotBinarySensorEntityDescription[Robot](
key="power_status", key="power_status",
name="Power status", translation_key="power_status",
device_class=BinarySensorDeviceClass.PLUG, device_class=BinarySensorDeviceClass.PLUG,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,

View file

@ -60,14 +60,14 @@ class RobotButtonEntityDescription(ButtonEntityDescription, RequiredKeysMixin[_R
LITTER_ROBOT_BUTTON = RobotButtonEntityDescription[LitterRobot3]( LITTER_ROBOT_BUTTON = RobotButtonEntityDescription[LitterRobot3](
key="reset_waste_drawer", key="reset_waste_drawer",
name="Reset waste drawer", translation_key="reset_waste_drawer",
icon="mdi:delete-variant", icon="mdi:delete-variant",
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
press_fn=lambda robot: robot.reset_waste_drawer(), press_fn=lambda robot: robot.reset_waste_drawer(),
) )
FEEDER_ROBOT_BUTTON = RobotButtonEntityDescription[FeederRobot]( FEEDER_ROBOT_BUTTON = RobotButtonEntityDescription[FeederRobot](
key="give_snack", key="give_snack",
name="Give snack", translation_key="give_snack",
icon="mdi:candy-outline", icon="mdi:candy-outline",
press_fn=lambda robot: robot.give_snack(), press_fn=lambda robot: robot.give_snack(),
) )

View file

@ -50,7 +50,7 @@ class RobotSelectEntityDescription(
ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = { ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
LitterRobot: RobotSelectEntityDescription[LitterRobot, int]( LitterRobot: RobotSelectEntityDescription[LitterRobot, int](
key="cycle_delay", key="cycle_delay",
name="Clean cycle wait time minutes", translation_key="cycle_delay",
icon="mdi:timer-outline", icon="mdi:timer-outline",
unit_of_measurement=UnitOfTime.MINUTES, unit_of_measurement=UnitOfTime.MINUTES,
current_fn=lambda robot: robot.clean_cycle_wait_time_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]( LitterRobot4: RobotSelectEntityDescription[LitterRobot4, str](
key="panel_brightness", key="panel_brightness",
name="Panel brightness",
translation_key="brightness_level", translation_key="brightness_level",
current_fn=lambda robot: bri.name.lower() current_fn=lambda robot: bri.name.lower()
if (bri := robot.panel_brightness) is not None if (bri := robot.panel_brightness) is not None
@ -72,7 +71,7 @@ ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
), ),
FeederRobot: RobotSelectEntityDescription[FeederRobot, float]( FeederRobot: RobotSelectEntityDescription[FeederRobot, float](
key="meal_insert_size", key="meal_insert_size",
name="Meal insert size", translation_key="meal_insert_size",
icon="mdi:scale", icon="mdi:scale",
unit_of_measurement="cups", unit_of_measurement="cups",
current_fn=lambda robot: robot.meal_insert_size, current_fn=lambda robot: robot.meal_insert_size,

View file

@ -69,32 +69,31 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
LitterRobot: [ LitterRobot: [
RobotSensorEntityDescription[LitterRobot]( RobotSensorEntityDescription[LitterRobot](
key="waste_drawer_level", key="waste_drawer_level",
name="Waste drawer", translation_key="waste_drawer",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon_fn=lambda state: icon_for_gauge_level(state, 10), icon_fn=lambda state: icon_for_gauge_level(state, 10),
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
RobotSensorEntityDescription[LitterRobot]( RobotSensorEntityDescription[LitterRobot](
key="sleep_mode_start_time", key="sleep_mode_start_time",
name="Sleep mode start time", translation_key="sleep_mode_start_time",
device_class=SensorDeviceClass.TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
should_report=lambda robot: robot.sleep_mode_enabled, should_report=lambda robot: robot.sleep_mode_enabled,
), ),
RobotSensorEntityDescription[LitterRobot]( RobotSensorEntityDescription[LitterRobot](
key="sleep_mode_end_time", key="sleep_mode_end_time",
name="Sleep mode end time", translation_key="sleep_mode_end_time",
device_class=SensorDeviceClass.TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
should_report=lambda robot: robot.sleep_mode_enabled, should_report=lambda robot: robot.sleep_mode_enabled,
), ),
RobotSensorEntityDescription[LitterRobot]( RobotSensorEntityDescription[LitterRobot](
key="last_seen", key="last_seen",
name="Last seen", translation_key="last_seen",
device_class=SensorDeviceClass.TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
RobotSensorEntityDescription[LitterRobot]( RobotSensorEntityDescription[LitterRobot](
key="status_code", key="status_code",
name="Status code",
translation_key="status_code", translation_key="status_code",
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorDeviceClass.ENUM, device_class=SensorDeviceClass.ENUM,
@ -130,14 +129,14 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
LitterRobot4: [ LitterRobot4: [
RobotSensorEntityDescription[LitterRobot4]( RobotSensorEntityDescription[LitterRobot4](
key="litter_level", key="litter_level",
name="Litter level", translation_key="litter_level",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon_fn=lambda state: icon_for_gauge_level(state, 10), icon_fn=lambda state: icon_for_gauge_level(state, 10),
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
RobotSensorEntityDescription[LitterRobot4]( RobotSensorEntityDescription[LitterRobot4](
key="pet_weight", key="pet_weight",
name="Pet weight", translation_key="pet_weight",
native_unit_of_measurement=UnitOfMass.POUNDS, native_unit_of_measurement=UnitOfMass.POUNDS,
device_class=SensorDeviceClass.WEIGHT, device_class=SensorDeviceClass.WEIGHT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -146,7 +145,7 @@ ROBOT_SENSOR_MAP: dict[type[Robot], list[RobotSensorEntityDescription]] = {
FeederRobot: [ FeederRobot: [
RobotSensorEntityDescription[FeederRobot]( RobotSensorEntityDescription[FeederRobot](
key="food_level", key="food_level",
name="Food level", translation_key="food_level",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon_fn=lambda state: icon_for_gauge_level(state, 10), icon_fn=lambda state: icon_for_gauge_level(state, 10),
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

View file

@ -32,8 +32,46 @@
} }
}, },
"entity": { "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": { "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": { "status_code": {
"name": "Status code",
"state": { "state": {
"br": "Bonnet Removed", "br": "Bonnet Removed",
"ccc": "Clean Cycle Complete", "ccc": "Clean Cycle Complete",
@ -61,16 +99,44 @@
"sdf": "Drawer Full At Startup", "sdf": "Drawer Full At Startup",
"spf": "Pinch Detect At Startup" "spf": "Pinch Detect At Startup"
} }
},
"waste_drawer": {
"name": "Waste drawer"
} }
}, },
"select": { "select": {
"cycle_delay": {
"name": "Clean cycle wait time minutes"
},
"meal_insert_size": {
"name": "Meal insert size"
},
"brightness_level": { "brightness_level": {
"name": "Panel brightness",
"state": { "state": {
"low": "Low", "low": "Low",
"medium": "Medium", "medium": "Medium",
"high": "High" "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"
}
} }
} }
} }

View file

@ -36,13 +36,13 @@ class RobotSwitchEntityDescription(SwitchEntityDescription, RequiredKeysMixin[_R
ROBOT_SWITCHES = [ ROBOT_SWITCHES = [
RobotSwitchEntityDescription[LitterRobot | FeederRobot]( RobotSwitchEntityDescription[LitterRobot | FeederRobot](
key="night_light_mode_enabled", key="night_light_mode_enabled",
name="Night light mode", translation_key="night_light_mode",
icons=("mdi:lightbulb-on", "mdi:lightbulb-off"), icons=("mdi:lightbulb-on", "mdi:lightbulb-off"),
set_fn=lambda robot, value: robot.set_night_light(value), set_fn=lambda robot, value: robot.set_night_light(value),
), ),
RobotSwitchEntityDescription[LitterRobot | FeederRobot]( RobotSwitchEntityDescription[LitterRobot | FeederRobot](
key="panel_lock_enabled", key="panel_lock_enabled",
name="Panel lockout", translation_key="panel_lockout",
icons=("mdi:lock", "mdi:lock-open"), icons=("mdi:lock", "mdi:lock-open"),
set_fn=lambda robot, value: robot.set_panel_lockout(value), set_fn=lambda robot, value: robot.set_panel_lockout(value),
), ),

View file

@ -24,7 +24,7 @@ SCAN_INTERVAL = timedelta(days=1)
FIRMWARE_UPDATE_ENTITY = UpdateEntityDescription( FIRMWARE_UPDATE_ENTITY = UpdateEntityDescription(
key="firmware", key="firmware",
name="Firmware", translation_key="firmware",
device_class=UpdateDeviceClass.FIRMWARE, device_class=UpdateDeviceClass.FIRMWARE,
) )

View file

@ -42,7 +42,9 @@ LITTER_BOX_STATUS_STATE_MAP = {
LitterBoxStatus.OFF: STATE_OFF, 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( async def async_setup_entry(