Add icon translations to TP-Link (#112317)

This commit is contained in:
Joost Lekkerkerker 2024-03-05 14:19:08 +01:00 committed by GitHub
parent 98fa4b3d3c
commit c8a30cfda7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View file

@ -0,0 +1,16 @@
{
"entity": {
"switch": {
"led": {
"default": "mdi:led-off",
"state": {
"on": "mdi:led-on"
}
}
}
},
"services": {
"sequence_effect": "mdi:playlist-play",
"random_effect": "mdi:shuffle-variant"
}
}

View file

@ -61,7 +61,7 @@ class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity):
) -> None:
"""Initialize the LED switch."""
super().__init__(device, coordinator)
self._attr_unique_id = f"{self.device.mac}_led"
self._attr_unique_id = f"{device.mac}_led"
self._async_update_attrs()
@async_refresh_after
@ -77,9 +77,7 @@ class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity):
@callback
def _async_update_attrs(self) -> None:
"""Update the entity's attributes."""
is_on = self.device.led
self._attr_is_on = is_on
self._attr_icon = "mdi:led-on" if is_on else "mdi:led-off"
self._attr_is_on = self.device.led
@callback
def _handle_coordinator_update(self) -> None: