Move brightness icon map to icons.json (#136201)

This commit is contained in:
Nathan Spencer 2025-01-22 12:49:11 -07:00 committed by GitHub
parent 66115ce695
commit 208805a930
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 16 deletions

View File

@ -17,6 +17,14 @@
}
},
"select": {
"brightness_level": {
"default": "mdi:lightbulb-question",
"state": {
"low": "mdi:lightbulb-on-30",
"medium": "mdi:lightbulb-on-50",
"high": "mdi:lightbulb-on"
}
},
"cycle_delay": {
"default": "mdi:timer-outline"
},

View File

@ -20,13 +20,6 @@ from .hub import LitterRobotHub
_CastTypeT = TypeVar("_CastTypeT", int, float, str)
BRIGHTNESS_LEVEL_ICON_MAP: dict[BrightnessLevel | None, str] = {
BrightnessLevel.LOW: "mdi:lightbulb-on-30",
BrightnessLevel.MEDIUM: "mdi:lightbulb-on-50",
BrightnessLevel.HIGH: "mdi:lightbulb-on",
None: "mdi:lightbulb-question",
}
@dataclass(frozen=True)
class RequiredKeysMixin(Generic[_RobotT, _CastTypeT]):
@ -44,7 +37,6 @@ class RobotSelectEntityDescription(
"""A class that describes robot select entities."""
entity_category: EntityCategory = EntityCategory.CONFIG
icon_fn: Callable[[_RobotT], str] | None = None
ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
@ -66,7 +58,6 @@ ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
select_fn=lambda robot, opt: robot.set_panel_brightness(
BrightnessLevel[opt.upper()]
),
icon_fn=lambda robot: BRIGHTNESS_LEVEL_ICON_MAP[robot.panel_brightness],
),
FeederRobot: RobotSelectEntityDescription[FeederRobot, float](
key="meal_insert_size",
@ -113,13 +104,6 @@ class LitterRobotSelectEntity(
options = self.entity_description.options_fn(self.robot)
self._attr_options = list(map(str, options))
@property
def icon(self) -> str | None:
"""Return the icon to use in the frontend, if any."""
if icon_fn := self.entity_description.icon_fn:
return str(icon_fn(self.robot))
return super().icon
@property
def current_option(self) -> str | None:
"""Return the selected entity option to represent the entity state."""