From 33bc1f01a4246366096f84baa0d076c4651cc9ad Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 3 Jul 2023 03:42:02 +0200 Subject: [PATCH] Add entity translations for lifx (#95727) --- .../components/lifx/binary_sensor.py | 4 +--- homeassistant/components/lifx/button.py | 4 +--- homeassistant/components/lifx/entity.py | 2 ++ homeassistant/components/lifx/light.py | 2 +- homeassistant/components/lifx/select.py | 8 ++------ homeassistant/components/lifx/sensor.py | 4 +--- homeassistant/components/lifx/strings.json | 20 +++++++++++++++++++ 7 files changed, 28 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/lifx/binary_sensor.py b/homeassistant/components/lifx/binary_sensor.py index 110661b1c5c..5719c881d1f 100644 --- a/homeassistant/components/lifx/binary_sensor.py +++ b/homeassistant/components/lifx/binary_sensor.py @@ -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, diff --git a/homeassistant/components/lifx/button.py b/homeassistant/components/lifx/button.py index 00d216351a0..86e3bc569b1 100644 --- a/homeassistant/components/lifx/button.py +++ b/homeassistant/components/lifx/button.py @@ -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.""" diff --git a/homeassistant/components/lifx/entity.py b/homeassistant/components/lifx/entity.py index a86bda53cfd..5f08b6e7884 100644 --- a/homeassistant/components/lifx/entity.py +++ b/homeassistant/components/lifx/entity.py @@ -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) diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py index cb901dcbe47..0e56155832f 100644 --- a/homeassistant/components/lifx/light.py +++ b/homeassistant/components/lifx/light.py @@ -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"]: diff --git a/homeassistant/components/lifx/select.py b/homeassistant/components/lifx/select.py index 9ad457e0270..183e31dec1f 100644 --- a/homeassistant/components/lifx/select.py +++ b/homeassistant/components/lifx/select.py @@ -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, diff --git a/homeassistant/components/lifx/sensor.py b/homeassistant/components/lifx/sensor.py index 654b5285756..e10f9579bc3 100644 --- a/homeassistant/components/lifx/sensor.py +++ b/homeassistant/components/lifx/sensor.py @@ -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, diff --git a/homeassistant/components/lifx/strings.json b/homeassistant/components/lifx/strings.json index 93d3bd62abe..69055d6bbc6 100644 --- a/homeassistant/components/lifx/strings.json +++ b/homeassistant/components/lifx/strings.json @@ -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" + } + } } }