From aaa4ee79b8a862033d35ad93e986714b28cd4f82 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 27 Jun 2023 23:35:12 +0200 Subject: [PATCH] Add entity translations to HERE Travel time (#95412) --- .../components/here_travel_time/sensor.py | 13 +++++++------ .../components/here_travel_time/strings.json | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/here_travel_time/sensor.py b/homeassistant/components/here_travel_time/sensor.py index 91abfbd7652..537f782ad09 100644 --- a/homeassistant/components/here_travel_time/sensor.py +++ b/homeassistant/components/here_travel_time/sensor.py @@ -52,21 +52,21 @@ def sensor_descriptions(travel_mode: str) -> tuple[SensorEntityDescription, ...] """Construct SensorEntityDescriptions.""" return ( SensorEntityDescription( - name="Duration", + translation_key="duration", icon=ICONS.get(travel_mode, ICON_CAR), key=ATTR_DURATION, state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=UnitOfTime.MINUTES, ), SensorEntityDescription( - name="Duration in traffic", + translation_key="duration_in_traffic", icon=ICONS.get(travel_mode, ICON_CAR), key=ATTR_DURATION_IN_TRAFFIC, state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=UnitOfTime.MINUTES, ), SensorEntityDescription( - name="Distance", + translation_key="distance", icon=ICONS.get(travel_mode, ICON_CAR), key=ATTR_DISTANCE, state_class=SensorStateClass.MEASUREMENT, @@ -110,6 +110,8 @@ class HERETravelTimeSensor( ): """Representation of a HERE travel time sensor.""" + _attr_has_entity_name = True + def __init__( self, unique_id_prefix: str, @@ -128,7 +130,6 @@ class HERETravelTimeSensor( name=name, manufacturer="HERE Technologies", ) - self._attr_has_entity_name = True async def _async_restore_state(self) -> None: """Restore state.""" @@ -174,7 +175,7 @@ class OriginSensor(HERETravelTimeSensor): ) -> None: """Initialize the sensor.""" sensor_description = SensorEntityDescription( - name="Origin", + translation_key="origin", icon="mdi:store-marker", key=ATTR_ORIGIN_NAME, ) @@ -202,7 +203,7 @@ class DestinationSensor(HERETravelTimeSensor): ) -> None: """Initialize the sensor.""" sensor_description = SensorEntityDescription( - name="Destination", + translation_key="destination", icon="mdi:store-marker", key=ATTR_DESTINATION_NAME, ) diff --git a/homeassistant/components/here_travel_time/strings.json b/homeassistant/components/here_travel_time/strings.json index dab135efc82..2c031dc0a02 100644 --- a/homeassistant/components/here_travel_time/strings.json +++ b/homeassistant/components/here_travel_time/strings.json @@ -85,5 +85,24 @@ } } } + }, + "entity": { + "sensor": { + "duration": { + "name": "Duration" + }, + "duration_in_traffic": { + "name": "Duration in traffic" + }, + "distance": { + "name": "Distance" + }, + "origin": { + "name": "Origin" + }, + "destination": { + "name": "Destination" + } + } } }