mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Move brightness icon map to icons.json (#136201)
This commit is contained in:
parent
66115ce695
commit
208805a930
@ -17,6 +17,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"select": {
|
"select": {
|
||||||
|
"brightness_level": {
|
||||||
|
"default": "mdi:lightbulb-question",
|
||||||
|
"state": {
|
||||||
|
"low": "mdi:lightbulb-on-30",
|
||||||
|
"medium": "mdi:lightbulb-on-50",
|
||||||
|
"high": "mdi:lightbulb-on"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cycle_delay": {
|
"cycle_delay": {
|
||||||
"default": "mdi:timer-outline"
|
"default": "mdi:timer-outline"
|
||||||
},
|
},
|
||||||
|
@ -20,13 +20,6 @@ from .hub import LitterRobotHub
|
|||||||
|
|
||||||
_CastTypeT = TypeVar("_CastTypeT", int, float, str)
|
_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)
|
@dataclass(frozen=True)
|
||||||
class RequiredKeysMixin(Generic[_RobotT, _CastTypeT]):
|
class RequiredKeysMixin(Generic[_RobotT, _CastTypeT]):
|
||||||
@ -44,7 +37,6 @@ class RobotSelectEntityDescription(
|
|||||||
"""A class that describes robot select entities."""
|
"""A class that describes robot select entities."""
|
||||||
|
|
||||||
entity_category: EntityCategory = EntityCategory.CONFIG
|
entity_category: EntityCategory = EntityCategory.CONFIG
|
||||||
icon_fn: Callable[[_RobotT], str] | None = None
|
|
||||||
|
|
||||||
|
|
||||||
ROBOT_SELECT_MAP: dict[type[Robot], RobotSelectEntityDescription] = {
|
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(
|
select_fn=lambda robot, opt: robot.set_panel_brightness(
|
||||||
BrightnessLevel[opt.upper()]
|
BrightnessLevel[opt.upper()]
|
||||||
),
|
),
|
||||||
icon_fn=lambda robot: BRIGHTNESS_LEVEL_ICON_MAP[robot.panel_brightness],
|
|
||||||
),
|
),
|
||||||
FeederRobot: RobotSelectEntityDescription[FeederRobot, float](
|
FeederRobot: RobotSelectEntityDescription[FeederRobot, float](
|
||||||
key="meal_insert_size",
|
key="meal_insert_size",
|
||||||
@ -113,13 +104,6 @@ class LitterRobotSelectEntity(
|
|||||||
options = self.entity_description.options_fn(self.robot)
|
options = self.entity_description.options_fn(self.robot)
|
||||||
self._attr_options = list(map(str, options))
|
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
|
@property
|
||||||
def current_option(self) -> str | None:
|
def current_option(self) -> str | None:
|
||||||
"""Return the selected entity option to represent the entity state."""
|
"""Return the selected entity option to represent the entity state."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user