Add entity translations for lifx (#95727)

This commit is contained in:
Joost Lekkerkerker 2023-07-03 03:42:02 +02:00 committed by GitHub
parent b2611b595e
commit 33bc1f01a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 16 deletions

View file

@ -18,7 +18,7 @@ from .util import lifx_features
HEV_CYCLE_STATE_SENSOR = BinarySensorEntityDescription(
key=HEV_CYCLE_STATE,
name="Clean Cycle",
translation_key="clean_cycle",
entity_category=EntityCategory.DIAGNOSTIC,
device_class=BinarySensorDeviceClass.RUNNING,
)
@ -39,8 +39,6 @@ async def async_setup_entry(
class LIFXHevCycleBinarySensorEntity(LIFXEntity, BinarySensorEntity):
"""LIFX HEV cycle state binary sensor."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: LIFXUpdateCoordinator,

View file

@ -17,7 +17,6 @@ from .entity import LIFXEntity
RESTART_BUTTON_DESCRIPTION = ButtonEntityDescription(
key=RESTART,
name="Restart",
device_class=ButtonDeviceClass.RESTART,
entity_category=EntityCategory.CONFIG,
)
@ -45,8 +44,7 @@ async def async_setup_entry(
class LIFXButton(LIFXEntity, ButtonEntity):
"""Base LIFX button."""
_attr_has_entity_name: bool = True
_attr_should_poll: bool = False
_attr_should_poll = False
def __init__(self, coordinator: LIFXUpdateCoordinator) -> None:
"""Initialise a LIFX button."""

View file

@ -14,6 +14,8 @@ from .coordinator import LIFXUpdateCoordinator
class LIFXEntity(CoordinatorEntity[LIFXUpdateCoordinator]):
"""Representation of a LIFX entity with a coordinator."""
_attr_has_entity_name = True
def __init__(self, coordinator: LIFXUpdateCoordinator) -> None:
"""Initialise the light."""
super().__init__(coordinator)

View file

@ -112,6 +112,7 @@ class LIFXLight(LIFXEntity, LightEntity):
"""Representation of a LIFX light."""
_attr_supported_features = LightEntityFeature.TRANSITION | LightEntityFeature.EFFECT
_attr_name = None
def __init__(
self,
@ -131,7 +132,6 @@ class LIFXLight(LIFXEntity, LightEntity):
self.postponed_update: CALLBACK_TYPE | None = None
self.entry = entry
self._attr_unique_id = self.coordinator.serial_number
self._attr_name = self.bulb.label
self._attr_min_color_temp_kelvin = bulb_features["min_kelvin"]
self._attr_max_color_temp_kelvin = bulb_features["max_kelvin"]
if bulb_features["min_kelvin"] != bulb_features["max_kelvin"]:

View file

@ -23,14 +23,14 @@ THEME_NAMES = [theme_name.lower() for theme_name in ThemeLibrary().themes]
INFRARED_BRIGHTNESS_ENTITY = SelectEntityDescription(
key=INFRARED_BRIGHTNESS,
name="Infrared brightness",
translation_key="infrared_brightness",
entity_category=EntityCategory.CONFIG,
options=list(INFRARED_BRIGHTNESS_VALUES_MAP.values()),
)
THEME_ENTITY = SelectEntityDescription(
key=ATTR_THEME,
name="Theme",
translation_key="theme",
entity_category=EntityCategory.CONFIG,
options=THEME_NAMES,
)
@ -58,8 +58,6 @@ async def async_setup_entry(
class LIFXInfraredBrightnessSelectEntity(LIFXEntity, SelectEntity):
"""LIFX Nightvision infrared brightness configuration entity."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: LIFXUpdateCoordinator,
@ -90,8 +88,6 @@ class LIFXInfraredBrightnessSelectEntity(LIFXEntity, SelectEntity):
class LIFXThemeSelectEntity(LIFXEntity, SelectEntity):
"""Theme entity for LIFX multizone devices."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: LIFXUpdateCoordinator,

View file

@ -22,7 +22,7 @@ SCAN_INTERVAL = timedelta(seconds=30)
RSSI_SENSOR = SensorEntityDescription(
key=ATTR_RSSI,
name="RSSI",
translation_key="rssi",
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT,
@ -41,8 +41,6 @@ async def async_setup_entry(
class LIFXRssiSensor(LIFXEntity, SensorEntity):
"""LIFX RSSI sensor."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: LIFXUpdateCoordinator,

View file

@ -25,5 +25,25 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]"
}
},
"entity": {
"binary_sensor": {
"clean_cycle": {
"name": "Clean cycle"
}
},
"select": {
"infrared_brightness": {
"name": "Infrared brightness"
},
"theme": {
"name": "Theme"
}
},
"sensor": {
"rssi": {
"name": "RSSI"
}
}
}
}