From 29d7535b7b0b5f7a026281b24f4ed28803687309 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Fri, 7 Jul 2023 18:27:44 +0200 Subject: [PATCH] Add entity translations to Rainmachine (#96033) --- .../components/rainmachine/binary_sensor.py | 14 ++-- .../components/rainmachine/button.py | 1 - .../components/rainmachine/select.py | 2 +- .../components/rainmachine/sensor.py | 16 ++--- .../components/rainmachine/strings.json | 69 +++++++++++++++++++ .../components/rainmachine/switch.py | 4 +- .../components/rainmachine/update.py | 4 +- 7 files changed, 89 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/rainmachine/binary_sensor.py b/homeassistant/components/rainmachine/binary_sensor.py index 33650cfc2fe..7f93db67c4c 100644 --- a/homeassistant/components/rainmachine/binary_sensor.py +++ b/homeassistant/components/rainmachine/binary_sensor.py @@ -44,14 +44,14 @@ class RainMachineBinarySensorDescription( BINARY_SENSOR_DESCRIPTIONS = ( RainMachineBinarySensorDescription( key=TYPE_FLOW_SENSOR, - name="Flow sensor", + translation_key=TYPE_FLOW_SENSOR, icon="mdi:water-pump", api_category=DATA_PROVISION_SETTINGS, data_key="useFlowSensor", ), RainMachineBinarySensorDescription( key=TYPE_FREEZE, - name="Freeze restrictions", + translation_key=TYPE_FREEZE, icon="mdi:cancel", entity_category=EntityCategory.DIAGNOSTIC, api_category=DATA_RESTRICTIONS_CURRENT, @@ -59,7 +59,7 @@ BINARY_SENSOR_DESCRIPTIONS = ( ), RainMachineBinarySensorDescription( key=TYPE_HOURLY, - name="Hourly restrictions", + translation_key=TYPE_HOURLY, icon="mdi:cancel", entity_category=EntityCategory.DIAGNOSTIC, api_category=DATA_RESTRICTIONS_CURRENT, @@ -67,7 +67,7 @@ BINARY_SENSOR_DESCRIPTIONS = ( ), RainMachineBinarySensorDescription( key=TYPE_MONTH, - name="Month restrictions", + translation_key=TYPE_MONTH, icon="mdi:cancel", entity_category=EntityCategory.DIAGNOSTIC, api_category=DATA_RESTRICTIONS_CURRENT, @@ -75,7 +75,7 @@ BINARY_SENSOR_DESCRIPTIONS = ( ), RainMachineBinarySensorDescription( key=TYPE_RAINDELAY, - name="Rain delay restrictions", + translation_key=TYPE_RAINDELAY, icon="mdi:cancel", entity_category=EntityCategory.DIAGNOSTIC, api_category=DATA_RESTRICTIONS_CURRENT, @@ -83,7 +83,7 @@ BINARY_SENSOR_DESCRIPTIONS = ( ), RainMachineBinarySensorDescription( key=TYPE_RAINSENSOR, - name="Rain sensor restrictions", + translation_key=TYPE_RAINSENSOR, icon="mdi:cancel", entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, @@ -92,7 +92,7 @@ BINARY_SENSOR_DESCRIPTIONS = ( ), RainMachineBinarySensorDescription( key=TYPE_WEEKDAY, - name="Weekday restrictions", + translation_key=TYPE_WEEKDAY, icon="mdi:cancel", entity_category=EntityCategory.DIAGNOSTIC, api_category=DATA_RESTRICTIONS_CURRENT, diff --git a/homeassistant/components/rainmachine/button.py b/homeassistant/components/rainmachine/button.py index d4ed17c72e9..82829094957 100644 --- a/homeassistant/components/rainmachine/button.py +++ b/homeassistant/components/rainmachine/button.py @@ -51,7 +51,6 @@ async def _async_reboot(controller: Controller) -> None: BUTTON_DESCRIPTIONS = ( RainMachineButtonDescription( key=BUTTON_KIND_REBOOT, - name="Reboot", api_category=DATA_PROVISION_SETTINGS, push_action=_async_reboot, ), diff --git a/homeassistant/components/rainmachine/select.py b/homeassistant/components/rainmachine/select.py index f482deb4ef4..2a5bc93f601 100644 --- a/homeassistant/components/rainmachine/select.py +++ b/homeassistant/components/rainmachine/select.py @@ -59,7 +59,7 @@ TYPE_FREEZE_PROTECTION_TEMPERATURE = "freeze_protection_temperature" SELECT_DESCRIPTIONS = ( FreezeProtectionSelectDescription( key=TYPE_FREEZE_PROTECTION_TEMPERATURE, - name="Freeze protection temperature", + translation_key=TYPE_FREEZE_PROTECTION_TEMPERATURE, icon="mdi:thermometer", entity_category=EntityCategory.CONFIG, api_category=DATA_RESTRICTIONS_UNIVERSAL, diff --git a/homeassistant/components/rainmachine/sensor.py b/homeassistant/components/rainmachine/sensor.py index 22943d73fcb..6333dcc82f4 100644 --- a/homeassistant/components/rainmachine/sensor.py +++ b/homeassistant/components/rainmachine/sensor.py @@ -69,7 +69,7 @@ class RainMachineSensorCompletionTimerDescription( SENSOR_DESCRIPTIONS = ( RainMachineSensorDataDescription( key=TYPE_FLOW_SENSOR_CLICK_M3, - name="Flow sensor clicks per cubic meter", + translation_key=TYPE_FLOW_SENSOR_CLICK_M3, icon="mdi:water-pump", native_unit_of_measurement=f"clicks/{UnitOfVolume.CUBIC_METERS}", entity_category=EntityCategory.DIAGNOSTIC, @@ -80,7 +80,7 @@ SENSOR_DESCRIPTIONS = ( ), RainMachineSensorDataDescription( key=TYPE_FLOW_SENSOR_CONSUMED_LITERS, - name="Flow sensor consumed liters", + translation_key=TYPE_FLOW_SENSOR_CONSUMED_LITERS, icon="mdi:water-pump", device_class=SensorDeviceClass.WATER, entity_category=EntityCategory.DIAGNOSTIC, @@ -92,7 +92,7 @@ SENSOR_DESCRIPTIONS = ( ), RainMachineSensorDataDescription( key=TYPE_FLOW_SENSOR_LEAK_CLICKS, - name="Flow sensor leak clicks", + translation_key=TYPE_FLOW_SENSOR_LEAK_CLICKS, icon="mdi:pipe-leak", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement="clicks", @@ -103,7 +103,7 @@ SENSOR_DESCRIPTIONS = ( ), RainMachineSensorDataDescription( key=TYPE_FLOW_SENSOR_LEAK_VOLUME, - name="Flow sensor leak volume", + translation_key=TYPE_FLOW_SENSOR_LEAK_VOLUME, icon="mdi:pipe-leak", device_class=SensorDeviceClass.WATER, entity_category=EntityCategory.DIAGNOSTIC, @@ -115,7 +115,7 @@ SENSOR_DESCRIPTIONS = ( ), RainMachineSensorDataDescription( key=TYPE_FLOW_SENSOR_START_INDEX, - name="Flow sensor start index", + translation_key=TYPE_FLOW_SENSOR_START_INDEX, icon="mdi:water-pump", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement="index", @@ -125,7 +125,7 @@ SENSOR_DESCRIPTIONS = ( ), RainMachineSensorDataDescription( key=TYPE_FLOW_SENSOR_WATERING_CLICKS, - name="Flow sensor clicks", + translation_key=TYPE_FLOW_SENSOR_WATERING_CLICKS, icon="mdi:water-pump", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement="clicks", @@ -136,7 +136,7 @@ SENSOR_DESCRIPTIONS = ( ), RainMachineSensorDataDescription( key=TYPE_LAST_LEAK_DETECTED, - name="Last leak detected", + translation_key=TYPE_LAST_LEAK_DETECTED, icon="mdi:pipe-leak", entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, @@ -147,7 +147,7 @@ SENSOR_DESCRIPTIONS = ( ), RainMachineSensorDataDescription( key=TYPE_RAIN_SENSOR_RAIN_START, - name="Rain sensor rain start", + translation_key=TYPE_RAIN_SENSOR_RAIN_START, icon="mdi:weather-pouring", entity_category=EntityCategory.DIAGNOSTIC, entity_registry_enabled_default=False, diff --git a/homeassistant/components/rainmachine/strings.json b/homeassistant/components/rainmachine/strings.json index 9991fd31e03..884d05359a6 100644 --- a/homeassistant/components/rainmachine/strings.json +++ b/homeassistant/components/rainmachine/strings.json @@ -28,5 +28,74 @@ } } } + }, + "entity": { + "binary_sensor": { + "flow_sensor": { + "name": "Flow sensor" + }, + "freeze": { + "name": "Freeze restrictions" + }, + "hourly": { + "name": "Hourly restrictions" + }, + "month": { + "name": "Month restrictions" + }, + "raindelay": { + "name": "Rain delay restrictions" + }, + "rainsensor": { + "name": "Rain sensor restrictions" + }, + "weekday": { + "name": "Weekday restrictions" + } + }, + "select": { + "freeze_protection_temperature": { + "name": "Freeze protection temperature" + } + }, + "sensor": { + "flow_sensor_clicks_cubic_meter": { + "name": "Flow sensor clicks per cubic meter" + }, + "flow_sensor_consumed_liters": { + "name": "Flow sensor consumed liters" + }, + "flow_sensor_leak_clicks": { + "name": "Flow sensor leak clicks" + }, + "flow_sensor_leak_volume": { + "name": "Flow sensor leak volume" + }, + "flow_sensor_start_index": { + "name": "Flow sensor start index" + }, + "flow_sensor_watering_clicks": { + "name": "Flow sensor clicks" + }, + "last_leak_detected": { + "name": "Last leak detected" + }, + "rain_sensor_rain_start": { + "name": "Rain sensor rain start" + } + }, + "switch": { + "freeze_protect_enabled": { + "name": "Freeze protection" + }, + "hot_days_extra_watering": { + "name": "Extra water on hot days" + } + }, + "update": { + "firmware": { + "name": "Firmware" + } + } } } diff --git a/homeassistant/components/rainmachine/switch.py b/homeassistant/components/rainmachine/switch.py index 60db5085951..e6ed92d04dc 100644 --- a/homeassistant/components/rainmachine/switch.py +++ b/homeassistant/components/rainmachine/switch.py @@ -161,14 +161,14 @@ TYPE_RESTRICTIONS_HOT_DAYS_EXTRA_WATERING = "hot_days_extra_watering" RESTRICTIONS_SWITCH_DESCRIPTIONS = ( RainMachineRestrictionSwitchDescription( key=TYPE_RESTRICTIONS_FREEZE_PROTECT_ENABLED, - name="Freeze protection", + translation_key=TYPE_RESTRICTIONS_FREEZE_PROTECT_ENABLED, icon="mdi:snowflake-alert", api_category=DATA_RESTRICTIONS_UNIVERSAL, data_key="freezeProtectEnabled", ), RainMachineRestrictionSwitchDescription( key=TYPE_RESTRICTIONS_HOT_DAYS_EXTRA_WATERING, - name="Extra water on hot days", + translation_key=TYPE_RESTRICTIONS_HOT_DAYS_EXTRA_WATERING, icon="mdi:heat-wave", api_category=DATA_RESTRICTIONS_UNIVERSAL, data_key="hotDaysExtraWatering", diff --git a/homeassistant/components/rainmachine/update.py b/homeassistant/components/rainmachine/update.py index f603cf0ccd7..372319ba9a0 100644 --- a/homeassistant/components/rainmachine/update.py +++ b/homeassistant/components/rainmachine/update.py @@ -44,7 +44,7 @@ UPDATE_STATE_MAP = { UPDATE_DESCRIPTION = RainMachineEntityDescription( key="update", - name="Firmware", + translation_key="firmware", api_category=DATA_MACHINE_FIRMWARE_UPDATE_STATUS, ) @@ -52,7 +52,7 @@ UPDATE_DESCRIPTION = RainMachineEntityDescription( async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: - """Set up WLED update based on a config entry.""" + """Set up Rainmachine update based on a config entry.""" data: RainMachineData = hass.data[DOMAIN][entry.entry_id] async_add_entities([RainMachineUpdateEntity(entry, data, UPDATE_DESCRIPTION)])