Add icon translations to Bond (#111349)

This commit is contained in:
Joost Lekkerkerker 2024-03-12 21:52:06 +01:00 committed by GitHub
parent 20647af5ae
commit 688395a3e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 136 additions and 29 deletions

View File

@ -36,7 +36,7 @@ class BondButtonEntityDescription(ButtonEntityDescription):
STOP_BUTTON = BondButtonEntityDescription( STOP_BUTTON = BondButtonEntityDescription(
key=Action.STOP, key=Action.STOP,
name="Stop Actions", name="Stop Actions",
icon="mdi:stop-circle-outline", translation_key="stop_actions",
mutually_exclusive=None, mutually_exclusive=None,
argument=None, argument=None,
) )
@ -46,175 +46,175 @@ BUTTONS: tuple[BondButtonEntityDescription, ...] = (
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.TOGGLE_POWER, key=Action.TOGGLE_POWER,
name="Toggle Power", name="Toggle Power",
icon="mdi:power-cycle", translation_key="toggle_power",
mutually_exclusive=Action.TURN_ON, mutually_exclusive=Action.TURN_ON,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.TOGGLE_LIGHT, key=Action.TOGGLE_LIGHT,
name="Toggle Light", name="Toggle Light",
icon="mdi:lightbulb", translation_key="toggle_light",
mutually_exclusive=Action.TURN_LIGHT_ON, mutually_exclusive=Action.TURN_LIGHT_ON,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.INCREASE_BRIGHTNESS, key=Action.INCREASE_BRIGHTNESS,
name="Increase Brightness", name="Increase Brightness",
icon="mdi:brightness-7", translation_key="increase_brightness",
mutually_exclusive=Action.SET_BRIGHTNESS, mutually_exclusive=Action.SET_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.DECREASE_BRIGHTNESS, key=Action.DECREASE_BRIGHTNESS,
name="Decrease Brightness", name="Decrease Brightness",
icon="mdi:brightness-1", translation_key="decrease_brightness",
mutually_exclusive=Action.SET_BRIGHTNESS, mutually_exclusive=Action.SET_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.TOGGLE_UP_LIGHT, key=Action.TOGGLE_UP_LIGHT,
name="Toggle Up Light", name="Toggle Up Light",
icon="mdi:lightbulb", translation_key="toggle_up_light",
mutually_exclusive=Action.TURN_UP_LIGHT_ON, mutually_exclusive=Action.TURN_UP_LIGHT_ON,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.TOGGLE_DOWN_LIGHT, key=Action.TOGGLE_DOWN_LIGHT,
name="Toggle Down Light", name="Toggle Down Light",
icon="mdi:lightbulb", translation_key="toggle_down_light",
mutually_exclusive=Action.TURN_DOWN_LIGHT_ON, mutually_exclusive=Action.TURN_DOWN_LIGHT_ON,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.START_DIMMER, key=Action.START_DIMMER,
name="Start Dimmer", name="Start Dimmer",
icon="mdi:brightness-percent", translation_key="start_dimmer",
mutually_exclusive=Action.SET_BRIGHTNESS, mutually_exclusive=Action.SET_BRIGHTNESS,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.START_UP_LIGHT_DIMMER, key=Action.START_UP_LIGHT_DIMMER,
name="Start Up Light Dimmer", name="Start Up Light Dimmer",
icon="mdi:brightness-percent", translation_key="start_up_light_dimmer",
mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.START_DOWN_LIGHT_DIMMER, key=Action.START_DOWN_LIGHT_DIMMER,
name="Start Down Light Dimmer", name="Start Down Light Dimmer",
icon="mdi:brightness-percent", translation_key="start_down_light_dimmer",
mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.START_INCREASING_BRIGHTNESS, key=Action.START_INCREASING_BRIGHTNESS,
name="Start Increasing Brightness", name="Start Increasing Brightness",
icon="mdi:brightness-percent", translation_key="start_increasing_brightness",
mutually_exclusive=Action.SET_BRIGHTNESS, mutually_exclusive=Action.SET_BRIGHTNESS,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.START_DECREASING_BRIGHTNESS, key=Action.START_DECREASING_BRIGHTNESS,
name="Start Decreasing Brightness", name="Start Decreasing Brightness",
icon="mdi:brightness-percent", translation_key="start_decreasing_brightness",
mutually_exclusive=Action.SET_BRIGHTNESS, mutually_exclusive=Action.SET_BRIGHTNESS,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.INCREASE_UP_LIGHT_BRIGHTNESS, key=Action.INCREASE_UP_LIGHT_BRIGHTNESS,
name="Increase Up Light Brightness", name="Increase Up Light Brightness",
icon="mdi:brightness-percent", translation_key="increase_up_light_brightness",
mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.DECREASE_UP_LIGHT_BRIGHTNESS, key=Action.DECREASE_UP_LIGHT_BRIGHTNESS,
name="Decrease Up Light Brightness", name="Decrease Up Light Brightness",
icon="mdi:brightness-percent", translation_key="decrease_up_light_brightness",
mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.INCREASE_DOWN_LIGHT_BRIGHTNESS, key=Action.INCREASE_DOWN_LIGHT_BRIGHTNESS,
name="Increase Down Light Brightness", name="Increase Down Light Brightness",
icon="mdi:brightness-percent", translation_key="increase_down_light_brightness",
mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.DECREASE_DOWN_LIGHT_BRIGHTNESS, key=Action.DECREASE_DOWN_LIGHT_BRIGHTNESS,
name="Decrease Down Light Brightness", name="Decrease Down Light Brightness",
icon="mdi:brightness-percent", translation_key="decrease_down_light_brightness",
mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.CYCLE_UP_LIGHT_BRIGHTNESS, key=Action.CYCLE_UP_LIGHT_BRIGHTNESS,
name="Cycle Up Light Brightness", name="Cycle Up Light Brightness",
icon="mdi:brightness-percent", translation_key="cycle_up_light_brightness",
mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_UP_LIGHT_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.CYCLE_DOWN_LIGHT_BRIGHTNESS, key=Action.CYCLE_DOWN_LIGHT_BRIGHTNESS,
name="Cycle Down Light Brightness", name="Cycle Down Light Brightness",
icon="mdi:brightness-percent", translation_key="cycle_down_light_brightness",
mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS, mutually_exclusive=Action.SET_DOWN_LIGHT_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.CYCLE_BRIGHTNESS, key=Action.CYCLE_BRIGHTNESS,
name="Cycle Brightness", name="Cycle Brightness",
icon="mdi:brightness-percent", translation_key="cycle_brightness",
mutually_exclusive=Action.SET_BRIGHTNESS, mutually_exclusive=Action.SET_BRIGHTNESS,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.INCREASE_SPEED, key=Action.INCREASE_SPEED,
name="Increase Speed", name="Increase Speed",
icon="mdi:skew-more", translation_key="increase_speed",
mutually_exclusive=Action.SET_SPEED, mutually_exclusive=Action.SET_SPEED,
argument=1, argument=1,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.DECREASE_SPEED, key=Action.DECREASE_SPEED,
name="Decrease Speed", name="Decrease Speed",
icon="mdi:skew-less", translation_key="decrease_speed",
mutually_exclusive=Action.SET_SPEED, mutually_exclusive=Action.SET_SPEED,
argument=1, argument=1,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.TOGGLE_DIRECTION, key=Action.TOGGLE_DIRECTION,
name="Toggle Direction", name="Toggle Direction",
icon="mdi:directions-fork", translation_key="toggle_direction",
mutually_exclusive=Action.SET_DIRECTION, mutually_exclusive=Action.SET_DIRECTION,
argument=None, argument=None,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.INCREASE_TEMPERATURE, key=Action.INCREASE_TEMPERATURE,
name="Increase Temperature", name="Increase Temperature",
icon="mdi:thermometer-plus", translation_key="increase_temperature",
mutually_exclusive=None, mutually_exclusive=None,
argument=1, argument=1,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.DECREASE_TEMPERATURE, key=Action.DECREASE_TEMPERATURE,
name="Decrease Temperature", name="Decrease Temperature",
icon="mdi:thermometer-minus", translation_key="decrease_temperature",
mutually_exclusive=None, mutually_exclusive=None,
argument=1, argument=1,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.INCREASE_FLAME, key=Action.INCREASE_FLAME,
name="Increase Flame", name="Increase Flame",
icon="mdi:fire", translation_key="increase_flame",
mutually_exclusive=None, mutually_exclusive=None,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.DECREASE_FLAME, key=Action.DECREASE_FLAME,
name="Decrease Flame", name="Decrease Flame",
icon="mdi:fire-off", translation_key="decrease_flame",
mutually_exclusive=None, mutually_exclusive=None,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
@ -227,14 +227,14 @@ BUTTONS: tuple[BondButtonEntityDescription, ...] = (
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.INCREASE_POSITION, key=Action.INCREASE_POSITION,
name="Increase Position", name="Increase Position",
icon="mdi:plus-box", translation_key="increase_position",
mutually_exclusive=Action.SET_POSITION, mutually_exclusive=Action.SET_POSITION,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),
BondButtonEntityDescription( BondButtonEntityDescription(
key=Action.DECREASE_POSITION, key=Action.DECREASE_POSITION,
name="Decrease Position", name="Decrease Position",
icon="mdi:minus-box", translation_key="decrease_position",
mutually_exclusive=Action.SET_POSITION, mutually_exclusive=Action.SET_POSITION,
argument=STEP_SIZE, argument=STEP_SIZE,
), ),

View File

@ -0,0 +1,107 @@
{
"entity": {
"button": {
"stop_actions": {
"default": "mdi:stop-circle-outline"
},
"toggle_power": {
"default": "mdi:power-cycle"
},
"toggle_light": {
"default": "mdi:lightbulb"
},
"increase_brightness": {
"default": "mdi:brightness-7"
},
"decrease_brightness": {
"default": "mdi:brightness-1"
},
"toggle_up_light": {
"default": "mdi:lightbulb"
},
"toggle_down_light": {
"default": "mdi:lightbulb"
},
"start_dimmer": {
"default": "mdi:brightness-percent"
},
"start_up_light_dimmer": {
"default": "mdi:brightness-percent"
},
"start_down_light_dimmer": {
"default": "mdi:brightness-percent"
},
"start_increasing_brightness": {
"default": "mdi:brightness-percent"
},
"start_decreasing_brightness": {
"default": "mdi:brightness-percent"
},
"increase_up_light_brightness": {
"default": "mdi:brightness-percent"
},
"decrease_up_light_brightness": {
"default": "mdi:brightness-percent"
},
"increase_down_light_brightness": {
"default": "mdi:brightness-percent"
},
"decrease_down_light_brightness": {
"default": "mdi:brightness-percent"
},
"cycle_up_light_brightness": {
"default": "mdi:brightness-percent"
},
"cycle_down_light_brightness": {
"default": "mdi:brightness-percent"
},
"cycle_brightness": {
"default": "mdi:brightness-percent"
},
"increase_speed": {
"default": "mdi:skew-more"
},
"decrease_speed": {
"default": "mdi:skew-less"
},
"toggle_direction": {
"default": "mdi:directions-fork"
},
"increase_temperature": {
"default": "mdi:thermometer-plus"
},
"decrease_temperature": {
"default": "mdi:thermometer-minus"
},
"increase_flame": {
"default": "mdi:fire"
},
"decrease_flame": {
"default": "mdi:fire-off"
},
"increase_position": {
"default": "mdi:plus-box"
},
"decrease_position": {
"default": "mdi:minus-box"
}
},
"light": {
"fireplace": {
"default": "mdi:fireplace-off",
"state": {
"on": "mdi:fireplace"
}
}
}
},
"services": {
"set_fan_speed_tracked_state": "mdi:fan",
"set_switch_power_tracked_state": "mdi:toggle-switch-variant",
"set_light_power_tracked_state": "mdi:lightbulb",
"set_light_brightness_tracked_state": "mdi:lightbulb-on",
"start_increasing_brightness": "mdi:brightness-7",
"start_decreasing_brightness": "mdi:brightness-1",
"stop": "mdi:stop"
}
}

View File

@ -274,6 +274,7 @@ class BondFireplace(BondEntity, LightEntity):
_attr_color_mode = ColorMode.BRIGHTNESS _attr_color_mode = ColorMode.BRIGHTNESS
_attr_supported_color_modes = {ColorMode.BRIGHTNESS} _attr_supported_color_modes = {ColorMode.BRIGHTNESS}
_attr_translation_key = "fireplace"
def _apply_state(self) -> None: def _apply_state(self) -> None:
state = self._device.state state = self._device.state
@ -281,7 +282,6 @@ class BondFireplace(BondEntity, LightEntity):
flame = state.get("flame") flame = state.get("flame")
self._attr_is_on = power == 1 self._attr_is_on = power == 1
self._attr_brightness = round(flame * 255 / 100) if flame else None self._attr_brightness = round(flame * 255 / 100) if flame else None
self._attr_icon = "mdi:fireplace" if power == 1 else "mdi:fireplace-off"
async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the fireplace on.""" """Turn the fireplace on."""