From 8f761f44bdf79f33161db98a18c50855f3db73d7 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 9 Dec 2022 08:22:29 +0100 Subject: [PATCH] Add support for translating state attributes (#77028) * Allow defining state attributes in strings.json * Add all climate attributes * Remove support for custom device classes * Address review comments --- homeassistant/components/climate/strings.json | 77 +++++++++++++ .../components/climate/translations/en.json | 101 ++++++++++++++++++ script/hassfest/translations.py | 12 +++ 3 files changed, 190 insertions(+) diff --git a/homeassistant/components/climate/strings.json b/homeassistant/components/climate/strings.json index 1caf184b998..8c6c8f2d97a 100644 --- a/homeassistant/components/climate/strings.json +++ b/homeassistant/components/climate/strings.json @@ -25,5 +25,82 @@ "dry": "Dry", "fan_only": "Fan only" } + }, + "state_attributes": { + "_": { + "aux_heat": { "name": "Aux heat" }, + "current_humidity": { "name": "Current humidity" }, + "current_temperature": { "name": "Current temperature" }, + "fan_mode": { + "name": "Fan mode", + "state": { + "off": "[%key:common::state::off%]", + "on": "[%key:common::state::on%]", + "auto": "Auto", + "low": "Low", + "medium": "Medium", + "high": "High", + "top": "Top", + "middle": "Middle", + "focus": "Focus", + "diffuse": "Diffuse" + } + }, + "fan_modes": { + "name": "Fan modes" + }, + "humidity": { "name": "Target humidity" }, + "hvac_action": { + "name": "Current action", + "state": { + "off": "Off", + "heating": "Heating", + "cooling": "Cooling", + "drying": "Drying", + "idle": "Idle", + "fan": "Fan" + } + }, + "hvac_modes": { + "name": "HVAC modes" + }, + "max_humidity": { "name": "Max target humidity" }, + "max_temp": { "name": "Max target temperature" }, + "min_humidity": { "name": "Min target humidity" }, + "min_temp": { "name": "Min target temperature" }, + "preset_mode": { + "name": "Preset", + "state": { + "none": "None", + "eco": "Eco", + "away": "Away", + "boost": "Boost", + "comfort": "Comfort", + "home": "Home", + "sleep": "Sleep", + "activity": "Activity" + } + }, + "preset_modes": { + "name": "Presets" + }, + "swing_mode": { + "name": "Swing mode", + "state": { + "off": "[%key:common::state::off%]", + "on": "[%key:common::state::on%]", + "both": "Both", + "vertical": "Vertical", + "horizontal": "Horizontal" + } + }, + "swing_modes": { + "name": "Swing modes" + }, + "target_temp_high": { "name": "Upper target temperature" }, + "target_temp_low": { "name": "Lower target temperature" }, + "target_temp_step": { "name": "Target temperature step" }, + "temperature": { "name": "Target temperature" } + } } } diff --git a/homeassistant/components/climate/translations/en.json b/homeassistant/components/climate/translations/en.json index 92ff71be756..2f31a9a4bfc 100644 --- a/homeassistant/components/climate/translations/en.json +++ b/homeassistant/components/climate/translations/en.json @@ -25,5 +25,106 @@ "off": "Off" } }, + "state_attributes": { + "_": { + "aux_heat": { + "name": "Aux heat" + }, + "current_humidity": { + "name": "Current humidity" + }, + "current_temperature": { + "name": "Current temperature" + }, + "fan_mode": { + "name": "Fan mode", + "state": { + "auto": "Auto", + "diffuse": "Diffuse", + "focus": "Focus", + "high": "High", + "low": "Low", + "medium": "Medium", + "middle": "Middle", + "off": "Off", + "on": "On", + "top": "Top" + } + }, + "fan_modes": { + "name": "Fan modes" + }, + "humidity": { + "name": "Target humidity" + }, + "hvac_action": { + "name": "Current action", + "state": { + "cooling": "Cooling", + "drying": "Drying", + "fan": "Fan", + "heating": "Heating", + "idle": "Idle", + "off": "Off" + } + }, + "hvac_modes": { + "name": "HVAC modes" + }, + "max_humidity": { + "name": "Max target humidity" + }, + "max_temp": { + "name": "Max target temperature" + }, + "min_humidity": { + "name": "Min target humidity" + }, + "min_temp": { + "name": "Min target temperature" + }, + "preset_mode": { + "name": "Preset", + "state": { + "activity": "Activity", + "away": "Away", + "boost": "Boost", + "comfort": "Comfort", + "eco": "Eco", + "home": "Home", + "none": "None", + "sleep": "Sleep" + } + }, + "preset_modes": { + "name": "Presets" + }, + "swing_mode": { + "name": "Swing mode", + "state": { + "both": "Both", + "horizontal": "Horizontal", + "off": "Off", + "on": "On", + "vertical": "Vertical" + } + }, + "swing_modes": { + "name": "Swing modes" + }, + "target_temp_high": { + "name": "Upper target temperature" + }, + "target_temp_low": { + "name": "Lower target temperature" + }, + "target_temp_step": { + "name": "Target temperature step" + }, + "temperature": { + "name": "Target temperature" + } + } + }, "title": "Climate" } \ No newline at end of file diff --git a/script/hassfest/translations.py b/script/hassfest/translations.py index 31c49042c1d..8fdf5e89715 100644 --- a/script/hassfest/translations.py +++ b/script/hassfest/translations.py @@ -224,6 +224,18 @@ def gen_strings_schema(config: Config, integration: Integration) -> vol.Schema: cv.schema_with_slug_keys(str, slug_validator=lowercase_validator), slug_validator=vol.Any("_", cv.slug), ), + vol.Optional("state_attributes"): cv.schema_with_slug_keys( + cv.schema_with_slug_keys( + { + vol.Optional("name"): str, + vol.Optional("state"): cv.schema_with_slug_keys( + str, slug_validator=lowercase_validator + ), + }, + slug_validator=lowercase_validator, + ), + slug_validator=vol.Any("_", cv.slug), + ), vol.Optional("system_health"): { vol.Optional("info"): {str: cv.string_with_no_html} },