From 8c0594219feaecfeb11ac158ca6f46debea4571c Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sat, 23 Dec 2023 19:58:54 +0100 Subject: [PATCH] Add entity translations to Steamist (#96182) Co-authored-by: J. Nick Koston --- homeassistant/components/steamist/entity.py | 9 ++++----- homeassistant/components/steamist/sensor.py | 6 +++--- homeassistant/components/steamist/strings.json | 15 +++++++++++++++ homeassistant/components/steamist/switch.py | 6 ++++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/steamist/entity.py b/homeassistant/components/steamist/entity.py index 94b3d32eaa4..78340dab363 100644 --- a/homeassistant/components/steamist/entity.py +++ b/homeassistant/components/steamist/entity.py @@ -4,7 +4,7 @@ from __future__ import annotations from aiosteamist import SteamistStatus from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_MODEL, CONF_NAME +from homeassistant.const import CONF_HOST, CONF_MODEL from homeassistant.helpers import device_registry as dr from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity import Entity, EntityDescription @@ -14,7 +14,9 @@ from .coordinator import SteamistDataUpdateCoordinator class SteamistEntity(CoordinatorEntity[SteamistDataUpdateCoordinator], Entity): - """Representation of an Steamist entity.""" + """Representation of a Steamist entity.""" + + _attr_has_entity_name = True def __init__( self, @@ -25,13 +27,10 @@ class SteamistEntity(CoordinatorEntity[SteamistDataUpdateCoordinator], Entity): """Initialize the entity.""" super().__init__(coordinator) self.entity_description = description - if coordinator.device_name: - self._attr_name = f"{coordinator.device_name} {description.name}" self._attr_unique_id = f"{entry.entry_id}_{description.key}" if entry.unique_id: # Only present if UDP broadcast works self._attr_device_info = DeviceInfo( connections={(dr.CONNECTION_NETWORK_MAC, entry.unique_id)}, - name=entry.data[CONF_NAME], manufacturer="Steamist", model=entry.data[CONF_MODEL], configuration_url=f"http://{entry.data[CONF_HOST]}", diff --git a/homeassistant/components/steamist/sensor.py b/homeassistant/components/steamist/sensor.py index beb8eea47b9..dd51c485b4e 100644 --- a/homeassistant/components/steamist/sensor.py +++ b/homeassistant/components/steamist/sensor.py @@ -47,13 +47,13 @@ class SteamistSensorEntityDescription( SENSORS: tuple[SteamistSensorEntityDescription, ...] = ( SteamistSensorEntityDescription( key=_KEY_MINUTES_REMAIN, - name="Steam Minutes Remain", + translation_key="steam_minutes_remain", native_unit_of_measurement=UnitOfTime.MINUTES, value_fn=lambda status: status.minutes_remain, ), SteamistSensorEntityDescription( key=_KEY_TEMP, - name="Steam Temperature", + translation_key="steam_temperature", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda status: status.temp, @@ -79,7 +79,7 @@ async def async_setup_entry( class SteamistSensorEntity(SteamistEntity, SensorEntity): - """Representation of an Steamist steam switch.""" + """Representation of a Steamist steam switch.""" entity_description: SteamistSensorEntityDescription diff --git a/homeassistant/components/steamist/strings.json b/homeassistant/components/steamist/strings.json index 8827df6a08a..7bc3685472a 100644 --- a/homeassistant/components/steamist/strings.json +++ b/homeassistant/components/steamist/strings.json @@ -28,5 +28,20 @@ "no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]", "not_steamist_device": "Not a steamist device" } + }, + "entity": { + "sensor": { + "steam_minutes_remain": { + "name": "Steam minutes remain" + }, + "steam_temperature": { + "name": "Steam temperature" + } + }, + "switch": { + "steam_active": { + "name": "Steam active" + } + } } } diff --git a/homeassistant/components/steamist/switch.py b/homeassistant/components/steamist/switch.py index af9e894b70d..a9a7526c560 100644 --- a/homeassistant/components/steamist/switch.py +++ b/homeassistant/components/steamist/switch.py @@ -13,7 +13,9 @@ from .coordinator import SteamistDataUpdateCoordinator from .entity import SteamistEntity ACTIVE_SWITCH = SwitchEntityDescription( - key="active", icon="mdi:pot-steam", name="Steam Active" + key="active", + icon="mdi:pot-steam", + translation_key="steam_active", ) @@ -30,7 +32,7 @@ async def async_setup_entry( class SteamistSwitchEntity(SteamistEntity, SwitchEntity): - """Representation of an Steamist steam switch.""" + """Representation of a Steamist steam switch.""" @property def is_on(self) -> bool: