From d4f301f4a3ecdf5af222eb7e0dfc14251b7b8e41 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sat, 22 Jul 2023 17:39:11 +0200 Subject: [PATCH] Migrate Tolo to entity name (#96244) --- homeassistant/components/tolo/__init__.py | 2 + .../components/tolo/binary_sensor.py | 4 +- homeassistant/components/tolo/button.py | 2 +- homeassistant/components/tolo/climate.py | 2 +- homeassistant/components/tolo/fan.py | 2 +- homeassistant/components/tolo/light.py | 2 +- homeassistant/components/tolo/number.py | 6 +-- homeassistant/components/tolo/select.py | 1 - homeassistant/components/tolo/sensor.py | 10 ++-- homeassistant/components/tolo/strings.json | 52 +++++++++++++++++++ 10 files changed, 68 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/tolo/__init__.py b/homeassistant/components/tolo/__init__.py index a75cb7ce298..bb894753fb8 100644 --- a/homeassistant/components/tolo/__init__.py +++ b/homeassistant/components/tolo/__init__.py @@ -95,6 +95,8 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): class ToloSaunaCoordinatorEntity(CoordinatorEntity[ToloSaunaUpdateCoordinator]): """CoordinatorEntity for TOLO Sauna.""" + _attr_has_entity_name = True + def __init__( self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry ) -> None: diff --git a/homeassistant/components/tolo/binary_sensor.py b/homeassistant/components/tolo/binary_sensor.py index 0ee1cb08bb2..124cd45d78b 100644 --- a/homeassistant/components/tolo/binary_sensor.py +++ b/homeassistant/components/tolo/binary_sensor.py @@ -32,7 +32,7 @@ class ToloFlowInBinarySensor(ToloSaunaCoordinatorEntity, BinarySensorEntity): """Water In Valve Sensor.""" _attr_entity_category = EntityCategory.DIAGNOSTIC - _attr_name = "Water In Valve" + _attr_translation_key = "water_in_valve" _attr_device_class = BinarySensorDeviceClass.OPENING _attr_icon = "mdi:water-plus-outline" @@ -54,7 +54,7 @@ class ToloFlowOutBinarySensor(ToloSaunaCoordinatorEntity, BinarySensorEntity): """Water Out Valve Sensor.""" _attr_entity_category = EntityCategory.DIAGNOSTIC - _attr_name = "Water Out Valve" + _attr_translation_key = "water_out_valve" _attr_device_class = BinarySensorDeviceClass.OPENING _attr_icon = "mdi:water-minus-outline" diff --git a/homeassistant/components/tolo/button.py b/homeassistant/components/tolo/button.py index 5d041a74104..3b81477ab37 100644 --- a/homeassistant/components/tolo/button.py +++ b/homeassistant/components/tolo/button.py @@ -31,7 +31,7 @@ class ToloLampNextColorButton(ToloSaunaCoordinatorEntity, ButtonEntity): _attr_entity_category = EntityCategory.CONFIG _attr_icon = "mdi:palette" - _attr_name = "Next Color" + _attr_translation_key = "next_color" def __init__( self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry diff --git a/homeassistant/components/tolo/climate.py b/homeassistant/components/tolo/climate.py index 849a9f5b3ed..74f2a5a6f55 100644 --- a/homeassistant/components/tolo/climate.py +++ b/homeassistant/components/tolo/climate.py @@ -47,7 +47,7 @@ class SaunaClimate(ToloSaunaCoordinatorEntity, ClimateEntity): _attr_max_temp = DEFAULT_MAX_TEMP _attr_min_humidity = DEFAULT_MIN_HUMIDITY _attr_min_temp = DEFAULT_MIN_TEMP - _attr_name = "Sauna Climate" + _attr_name = None _attr_precision = PRECISION_WHOLE _attr_supported_features = ( ClimateEntityFeature.TARGET_TEMPERATURE diff --git a/homeassistant/components/tolo/fan.py b/homeassistant/components/tolo/fan.py index e767be9a3ce..7065290f2a8 100644 --- a/homeassistant/components/tolo/fan.py +++ b/homeassistant/components/tolo/fan.py @@ -26,7 +26,7 @@ async def async_setup_entry( class ToloFan(ToloSaunaCoordinatorEntity, FanEntity): """Sauna fan control.""" - _attr_name = "Fan" + _attr_translation_key = "fan" def __init__( self, coordinator: ToloSaunaUpdateCoordinator, entry: ConfigEntry diff --git a/homeassistant/components/tolo/light.py b/homeassistant/components/tolo/light.py index 715a1327e4b..4b76d4270c6 100644 --- a/homeassistant/components/tolo/light.py +++ b/homeassistant/components/tolo/light.py @@ -26,7 +26,7 @@ class ToloLight(ToloSaunaCoordinatorEntity, LightEntity): """Sauna light control.""" _attr_color_mode = ColorMode.ONOFF - _attr_name = "Sauna Light" + _attr_translation_key = "light" _attr_supported_color_modes = {ColorMode.ONOFF} def __init__( diff --git a/homeassistant/components/tolo/number.py b/homeassistant/components/tolo/number.py index aa12198b52c..3e07392c336 100644 --- a/homeassistant/components/tolo/number.py +++ b/homeassistant/components/tolo/number.py @@ -40,8 +40,8 @@ class ToloNumberEntityDescription( NUMBERS = ( ToloNumberEntityDescription( key="power_timer", + translation_key="power_timer", icon="mdi:power-settings", - name="Power Timer", native_unit_of_measurement=UnitOfTime.MINUTES, native_max_value=POWER_TIMER_MAX, getter=lambda settings: settings.power_timer, @@ -49,8 +49,8 @@ NUMBERS = ( ), ToloNumberEntityDescription( key="salt_bath_timer", + translation_key="salt_bath_timer", icon="mdi:shaker-outline", - name="Salt Bath Timer", native_unit_of_measurement=UnitOfTime.MINUTES, native_max_value=SALT_BATH_TIMER_MAX, getter=lambda settings: settings.salt_bath_timer, @@ -58,8 +58,8 @@ NUMBERS = ( ), ToloNumberEntityDescription( key="fan_timer", + translation_key="fan_timer", icon="mdi:fan-auto", - name="Fan Timer", native_unit_of_measurement=UnitOfTime.MINUTES, native_max_value=FAN_TIMER_MAX, getter=lambda settings: settings.fan_timer, diff --git a/homeassistant/components/tolo/select.py b/homeassistant/components/tolo/select.py index a47207d3d98..8e4ecb47f48 100644 --- a/homeassistant/components/tolo/select.py +++ b/homeassistant/components/tolo/select.py @@ -29,7 +29,6 @@ class ToloLampModeSelect(ToloSaunaCoordinatorEntity, SelectEntity): _attr_entity_category = EntityCategory.CONFIG _attr_icon = "mdi:lightbulb-multiple-outline" - _attr_name = "Lamp Mode" _attr_options = [lamp_mode.name.lower() for lamp_mode in LampMode] _attr_translation_key = "lamp_mode" diff --git a/homeassistant/components/tolo/sensor.py b/homeassistant/components/tolo/sensor.py index 2c5eccc1c1d..2ff901939ae 100644 --- a/homeassistant/components/tolo/sensor.py +++ b/homeassistant/components/tolo/sensor.py @@ -46,27 +46,27 @@ class ToloSensorEntityDescription( SENSORS = ( ToloSensorEntityDescription( key="water_level", + translation_key="water_level", entity_category=EntityCategory.DIAGNOSTIC, icon="mdi:waves-arrow-up", - name="Water Level", native_unit_of_measurement=PERCENTAGE, getter=lambda status: status.water_level_percent, availability_checker=None, ), ToloSensorEntityDescription( key="tank_temperature", + translation_key="tank_temperature", device_class=SensorDeviceClass.TEMPERATURE, entity_category=EntityCategory.DIAGNOSTIC, - name="Tank Temperature", native_unit_of_measurement=UnitOfTemperature.CELSIUS, getter=lambda status: status.tank_temperature, availability_checker=None, ), ToloSensorEntityDescription( key="power_timer_remaining", + translation_key="power_timer_remaining", entity_category=EntityCategory.DIAGNOSTIC, icon="mdi:power-settings", - name="Power Timer", native_unit_of_measurement=UnitOfTime.MINUTES, getter=lambda status: status.power_timer, availability_checker=lambda settings, status: status.power_on @@ -74,9 +74,9 @@ SENSORS = ( ), ToloSensorEntityDescription( key="salt_bath_timer_remaining", + translation_key="salt_bath_timer_remaining", entity_category=EntityCategory.DIAGNOSTIC, icon="mdi:shaker-outline", - name="Salt Bath Timer", native_unit_of_measurement=UnitOfTime.MINUTES, getter=lambda status: status.salt_bath_timer, availability_checker=lambda settings, status: status.salt_bath_on @@ -84,9 +84,9 @@ SENSORS = ( ), ToloSensorEntityDescription( key="fan_timer_remaining", + translation_key="fan_timer_remaining", entity_category=EntityCategory.DIAGNOSTIC, icon="mdi:fan-auto", - name="Fan Timer", native_unit_of_measurement=UnitOfTime.MINUTES, getter=lambda status: status.fan_timer, availability_checker=lambda settings, status: status.fan_on diff --git a/homeassistant/components/tolo/strings.json b/homeassistant/components/tolo/strings.json index 5e6647edae4..f48e26c5276 100644 --- a/homeassistant/components/tolo/strings.json +++ b/homeassistant/components/tolo/strings.json @@ -20,13 +20,65 @@ } }, "entity": { + "binary_sensor": { + "water_in_valve": { + "name": "Water in valve" + }, + "water_out_valve": { + "name": "Water out valve" + } + }, + "button": { + "next_color": { + "name": "Next color" + } + }, + "fan": { + "fan": { + "name": "[%key:component::fan::title%]" + } + }, + "light": { + "light": { + "name": "[%key:component::light::title%]" + } + }, + "number": { + "power_timer": { + "name": "Power timer" + }, + "salt_bath_timer": { + "name": "Salt bath timer" + }, + "fan_timer": { + "name": "Fan timer" + } + }, "select": { "lamp_mode": { + "name": "Lamp mode", "state": { "automatic": "Automatic", "manual": "Manual" } } + }, + "sensor": { + "water_level": { + "name": "Water level" + }, + "tank_temperature": { + "name": "Tank temperature" + }, + "power_timer_remaining": { + "name": "Power timer" + }, + "salt_bath_timer_remaining": { + "name": "Salt bath timer" + }, + "fan_timer_remaining": { + "name": "Fan timer" + } } } }