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

View File

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

View File

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

View File

@ -112,6 +112,7 @@ class LIFXLight(LIFXEntity, LightEntity):
"""Representation of a LIFX light.""" """Representation of a LIFX light."""
_attr_supported_features = LightEntityFeature.TRANSITION | LightEntityFeature.EFFECT _attr_supported_features = LightEntityFeature.TRANSITION | LightEntityFeature.EFFECT
_attr_name = None
def __init__( def __init__(
self, self,
@ -131,7 +132,6 @@ class LIFXLight(LIFXEntity, LightEntity):
self.postponed_update: CALLBACK_TYPE | None = None self.postponed_update: CALLBACK_TYPE | None = None
self.entry = entry self.entry = entry
self._attr_unique_id = self.coordinator.serial_number 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_min_color_temp_kelvin = bulb_features["min_kelvin"]
self._attr_max_color_temp_kelvin = bulb_features["max_kelvin"] self._attr_max_color_temp_kelvin = bulb_features["max_kelvin"]
if bulb_features["min_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( INFRARED_BRIGHTNESS_ENTITY = SelectEntityDescription(
key=INFRARED_BRIGHTNESS, key=INFRARED_BRIGHTNESS,
name="Infrared brightness", translation_key="infrared_brightness",
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
options=list(INFRARED_BRIGHTNESS_VALUES_MAP.values()), options=list(INFRARED_BRIGHTNESS_VALUES_MAP.values()),
) )
THEME_ENTITY = SelectEntityDescription( THEME_ENTITY = SelectEntityDescription(
key=ATTR_THEME, key=ATTR_THEME,
name="Theme", translation_key="theme",
entity_category=EntityCategory.CONFIG, entity_category=EntityCategory.CONFIG,
options=THEME_NAMES, options=THEME_NAMES,
) )
@ -58,8 +58,6 @@ async def async_setup_entry(
class LIFXInfraredBrightnessSelectEntity(LIFXEntity, SelectEntity): class LIFXInfraredBrightnessSelectEntity(LIFXEntity, SelectEntity):
"""LIFX Nightvision infrared brightness configuration entity.""" """LIFX Nightvision infrared brightness configuration entity."""
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
coordinator: LIFXUpdateCoordinator, coordinator: LIFXUpdateCoordinator,
@ -90,8 +88,6 @@ class LIFXInfraredBrightnessSelectEntity(LIFXEntity, SelectEntity):
class LIFXThemeSelectEntity(LIFXEntity, SelectEntity): class LIFXThemeSelectEntity(LIFXEntity, SelectEntity):
"""Theme entity for LIFX multizone devices.""" """Theme entity for LIFX multizone devices."""
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
coordinator: LIFXUpdateCoordinator, coordinator: LIFXUpdateCoordinator,

View File

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

View File

@ -25,5 +25,25 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]", "already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]" "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"
}
}
} }
} }