From 6033a7c3d44e6bd452c3442ea59154bebfaa8f1d Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Fri, 5 Jan 2024 12:32:32 +0100 Subject: [PATCH] Finish Efergy entity translations (#107152) --- homeassistant/components/efergy/sensor.py | 5 +++-- homeassistant/components/efergy/strings.json | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/efergy/sensor.py b/homeassistant/components/efergy/sensor.py index 809f1c531da79..dd8752dde7f70 100644 --- a/homeassistant/components/efergy/sensor.py +++ b/homeassistant/components/efergy/sensor.py @@ -96,7 +96,7 @@ ), SensorEntityDescription( key=CONF_CURRENT_VALUES, - name="Power Usage", + translation_key="power_usage", device_class=SensorDeviceClass.POWER, native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.MEASUREMENT, @@ -156,7 +156,8 @@ def __init__( super().__init__(api, server_unique_id) self.entity_description = description if description.key == CONF_CURRENT_VALUES: - self._attr_name = f"{description.name}_{'' if sid is None else sid}" + assert sid is not None + self._attr_translation_placeholders = {"sid": str(sid)} self._attr_unique_id = ( f"{server_unique_id}/{description.key}_{'' if sid is None else sid}" ) diff --git a/homeassistant/components/efergy/strings.json b/homeassistant/components/efergy/strings.json index 3b17bf07f1ae4..612c964487b8d 100644 --- a/homeassistant/components/efergy/strings.json +++ b/homeassistant/components/efergy/strings.json @@ -48,6 +48,9 @@ }, "cost_year": { "name": "Yearly energy cost" + }, + "power_usage": { + "name": "Power usage {sid}" } } }