From 21c619e7029a1c9e916ea27d24c76c9e88f51321 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 27 Jun 2023 22:24:41 +0200 Subject: [PATCH] Add entity translations to Guardian (#95411) --- .../components/guardian/binary_sensor.py | 6 ++-- homeassistant/components/guardian/button.py | 4 +-- homeassistant/components/guardian/sensor.py | 5 +--- .../components/guardian/strings.json | 28 +++++++++++++++++++ homeassistant/components/guardian/switch.py | 4 +-- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/guardian/binary_sensor.py b/homeassistant/components/guardian/binary_sensor.py index f9e8819a6af..7114d33f93a 100644 --- a/homeassistant/components/guardian/binary_sensor.py +++ b/homeassistant/components/guardian/binary_sensor.py @@ -49,12 +49,12 @@ class ValveControllerBinarySensorDescription( PAIRED_SENSOR_DESCRIPTIONS = ( BinarySensorEntityDescription( key=SENSOR_KIND_LEAK_DETECTED, - name="Leak detected", + translation_key="leak", device_class=BinarySensorDeviceClass.MOISTURE, ), BinarySensorEntityDescription( key=SENSOR_KIND_MOVED, - name="Recently moved", + translation_key="moved", device_class=BinarySensorDeviceClass.MOVING, entity_category=EntityCategory.DIAGNOSTIC, ), @@ -63,7 +63,7 @@ PAIRED_SENSOR_DESCRIPTIONS = ( VALVE_CONTROLLER_DESCRIPTIONS = ( ValveControllerBinarySensorDescription( key=SENSOR_KIND_LEAK_DETECTED, - name="Leak detected", + translation_key="leak", device_class=BinarySensorDeviceClass.MOISTURE, api_category=API_SYSTEM_ONBOARD_SENSOR_STATUS, ), diff --git a/homeassistant/components/guardian/button.py b/homeassistant/components/guardian/button.py index 7680707641c..c6363c9bcec 100644 --- a/homeassistant/components/guardian/button.py +++ b/homeassistant/components/guardian/button.py @@ -56,15 +56,15 @@ async def _async_valve_reset(client: Client) -> None: BUTTON_DESCRIPTIONS = ( ValveControllerButtonDescription( key=BUTTON_KIND_REBOOT, - name="Reboot", push_action=_async_reboot, + device_class=ButtonDeviceClass.RESTART, # Buttons don't actually need a coordinator; we give them one so they can # properly inherit from GuardianEntity: api_category=API_SYSTEM_DIAGNOSTICS, ), ValveControllerButtonDescription( key=BUTTON_KIND_RESET_VALVE_DIAGNOSTICS, - name="Reset valve diagnostics", + translation_key="reset_diagnostics", push_action=_async_valve_reset, # Buttons don't actually need a coordinator; we give them one so they can # properly inherit from GuardianEntity: diff --git a/homeassistant/components/guardian/sensor.py b/homeassistant/components/guardian/sensor.py index c46f6e221b2..c5fc77cc8f9 100644 --- a/homeassistant/components/guardian/sensor.py +++ b/homeassistant/components/guardian/sensor.py @@ -49,14 +49,12 @@ class ValveControllerSensorDescription( PAIRED_SENSOR_DESCRIPTIONS = ( SensorEntityDescription( key=SENSOR_KIND_BATTERY, - name="Battery", device_class=SensorDeviceClass.VOLTAGE, entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfElectricPotential.VOLT, ), SensorEntityDescription( key=SENSOR_KIND_TEMPERATURE, - name="Temperature", device_class=SensorDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT, state_class=SensorStateClass.MEASUREMENT, @@ -65,7 +63,6 @@ PAIRED_SENSOR_DESCRIPTIONS = ( VALVE_CONTROLLER_DESCRIPTIONS = ( ValveControllerSensorDescription( key=SENSOR_KIND_TEMPERATURE, - name="Temperature", device_class=SensorDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT, state_class=SensorStateClass.MEASUREMENT, @@ -73,7 +70,7 @@ VALVE_CONTROLLER_DESCRIPTIONS = ( ), ValveControllerSensorDescription( key=SENSOR_KIND_UPTIME, - name="Uptime", + translation_key="uptime", icon="mdi:timer", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfTime.MINUTES, diff --git a/homeassistant/components/guardian/strings.json b/homeassistant/components/guardian/strings.json index 683f13c8d36..dc3e6f4c17d 100644 --- a/homeassistant/components/guardian/strings.json +++ b/homeassistant/components/guardian/strings.json @@ -30,5 +30,33 @@ } } } + }, + "entity": { + "binary_sensor": { + "leak": { + "name": "Leak detected" + }, + "moved": { + "name": "Recently moved" + } + }, + "button": { + "reset_diagnostics": { + "name": "Reset valve diagnostics" + } + }, + "sensor": { + "uptime": { + "name": "Uptime" + } + }, + "switch": { + "onboard_access_point": { + "name": "Onboard access point" + }, + "valve_controller": { + "name": "Valve controller" + } + } } } diff --git a/homeassistant/components/guardian/switch.py b/homeassistant/components/guardian/switch.py index fe6ff937b84..4e2be5ae179 100644 --- a/homeassistant/components/guardian/switch.py +++ b/homeassistant/components/guardian/switch.py @@ -67,7 +67,7 @@ async def _async_open_valve(client: Client) -> None: VALVE_CONTROLLER_DESCRIPTIONS = ( ValveControllerSwitchDescription( key=SWITCH_KIND_ONBOARD_AP, - name="Onboard AP", + translation_key="onboard_access_point", icon="mdi:wifi", entity_category=EntityCategory.CONFIG, api_category=API_WIFI_STATUS, @@ -76,7 +76,7 @@ VALVE_CONTROLLER_DESCRIPTIONS = ( ), ValveControllerSwitchDescription( key=SWITCH_KIND_VALVE, - name="Valve controller", + translation_key="valve_controller", icon="mdi:water", api_category=API_VALVE_STATUS, off_action=_async_close_valve,