From a854a5620ff061614ffb96ee0b380d7ad6e59a4a Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 4 Apr 2023 06:01:46 +0200 Subject: [PATCH] Add entity name translations to Tractive (#90738) Add entity name translations --- .../components/tractive/binary_sensor.py | 2 +- .../components/tractive/device_tracker.py | 2 +- homeassistant/components/tractive/sensor.py | 7 ++--- .../components/tractive/strings.json | 31 +++++++++++++++++++ homeassistant/components/tractive/switch.py | 6 ++-- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/tractive/binary_sensor.py b/homeassistant/components/tractive/binary_sensor.py index c98bd0fa020..4b376941344 100644 --- a/homeassistant/components/tractive/binary_sensor.py +++ b/homeassistant/components/tractive/binary_sensor.py @@ -76,7 +76,7 @@ class TractiveBinarySensor(TractiveEntity, BinarySensorEntity): SENSOR_TYPE = BinarySensorEntityDescription( key=ATTR_BATTERY_CHARGING, - name="Tracker battery charging", + translation_key="tracker_battery_charging", device_class=BinarySensorDeviceClass.BATTERY_CHARGING, entity_category=EntityCategory.DIAGNOSTIC, ) diff --git a/homeassistant/components/tractive/device_tracker.py b/homeassistant/components/tractive/device_tracker.py index 0cb73723369..038461494d6 100644 --- a/homeassistant/components/tractive/device_tracker.py +++ b/homeassistant/components/tractive/device_tracker.py @@ -38,7 +38,7 @@ class TractiveDeviceTracker(TractiveEntity, TrackerEntity): _attr_has_entity_name = True _attr_icon = "mdi:paw" - _attr_name = "Tracker" + _attr_translation_key = "tracker" def __init__(self, user_id: str, item: Trackables) -> None: """Initialize tracker entity.""" diff --git a/homeassistant/components/tractive/sensor.py b/homeassistant/components/tractive/sensor.py index d9b92386bea..9c0f8f307ed 100644 --- a/homeassistant/components/tractive/sensor.py +++ b/homeassistant/components/tractive/sensor.py @@ -138,7 +138,7 @@ class TractiveActivitySensor(TractiveSensor): SENSOR_TYPES: tuple[TractiveSensorEntityDescription, ...] = ( TractiveSensorEntityDescription( key=ATTR_BATTERY_LEVEL, - name="Tracker battery level", + translation_key="tracker_battery_level", native_unit_of_measurement=PERCENTAGE, device_class=SensorDeviceClass.BATTERY, entity_class=TractiveHardwareSensor, @@ -148,20 +148,19 @@ SENSOR_TYPES: tuple[TractiveSensorEntityDescription, ...] = ( # Currently, only state operational and not_reporting are used # More states are available by polling the data key=ATTR_TRACKER_STATE, - name="Tracker state", translation_key="tracker_state", entity_class=TractiveHardwareSensor, ), TractiveSensorEntityDescription( key=ATTR_MINUTES_ACTIVE, - name="Minutes active", + translation_key="minutes_active", icon="mdi:clock-time-eight-outline", native_unit_of_measurement=UnitOfTime.MINUTES, entity_class=TractiveActivitySensor, ), TractiveSensorEntityDescription( key=ATTR_DAILY_GOAL, - name="Daily goal", + translation_key="daily_goal", icon="mdi:flag-checkered", native_unit_of_measurement=UnitOfTime.MINUTES, entity_class=TractiveActivitySensor, diff --git a/homeassistant/components/tractive/strings.json b/homeassistant/components/tractive/strings.json index f63f0cdf0af..d5aee51ed61 100644 --- a/homeassistant/components/tractive/strings.json +++ b/homeassistant/components/tractive/strings.json @@ -19,8 +19,28 @@ } }, "entity": { + "binary_sensor": { + "tracker_battery_charging": { + "name": "Tracker battery charging" + } + }, + "device_tracker": { + "tracker": { + "name": "Tracker" + } + }, "sensor": { + "daily_goal": { + "name": "Daily goal" + }, + "minutes_active": { + "name": "Minutes active" + }, + "tracker_battery_level": { + "name": "Tracker battery" + }, "tracker_state": { + "name": "Tracker state", "state": { "not_reporting": "Not reporting", "operational": "Operational", @@ -28,6 +48,17 @@ "system_startup": "System startup" } } + }, + "switch": { + "tracker_buzzer": { + "name": "Tracker buzzer" + }, + "tracker_led": { + "name": "Tracker LED" + }, + "live_tracking": { + "name": "Live tracking" + } } } } diff --git a/homeassistant/components/tractive/switch.py b/homeassistant/components/tractive/switch.py index a7f4a273bbe..7ae480d4f98 100644 --- a/homeassistant/components/tractive/switch.py +++ b/homeassistant/components/tractive/switch.py @@ -47,21 +47,21 @@ class TractiveSwitchEntityDescription( SWITCH_TYPES: tuple[TractiveSwitchEntityDescription, ...] = ( TractiveSwitchEntityDescription( key=ATTR_BUZZER, - name="Tracker buzzer", + translation_key="tracker_buzzer", icon="mdi:volume-high", method="async_set_buzzer", entity_category=EntityCategory.CONFIG, ), TractiveSwitchEntityDescription( key=ATTR_LED, - name="Tracker LED", + translation_key="tracker_led", icon="mdi:led-on", method="async_set_led", entity_category=EntityCategory.CONFIG, ), TractiveSwitchEntityDescription( key=ATTR_LIVE_TRACKING, - name="Live tracking", + translation_key="live_tracking", icon="mdi:map-marker-path", method="async_set_live_tracking", entity_category=EntityCategory.CONFIG,