From 2330af82a5a298363d48ce0926bcdac7d0dfd913 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 11 Jul 2023 23:17:09 +0200 Subject: [PATCH] Migrate climate services to support translations (#96314) * Migrate climate services to support translations * Apply suggestions from code review Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> --------- Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> --- .../components/climate/services.yaml | 84 ++-------- homeassistant/components/climate/strings.json | 153 ++++++++++++++++-- 2 files changed, 157 insertions(+), 80 deletions(-) diff --git a/homeassistant/components/climate/services.yaml b/homeassistant/components/climate/services.yaml index 33e114c87f5..405bb735b66 100644 --- a/homeassistant/components/climate/services.yaml +++ b/homeassistant/components/climate/services.yaml @@ -1,8 +1,6 @@ # Describes the format for available climate services set_aux_heat: - name: Turn on/off auxiliary heater - description: Turn auxiliary heater on/off for climate device. target: entity: domain: climate @@ -10,15 +8,11 @@ set_aux_heat: - climate.ClimateEntityFeature.AUX_HEAT fields: aux_heat: - name: Auxiliary heating - description: New value of auxiliary heater. required: true selector: boolean: set_preset_mode: - name: Set preset mode - description: Set preset mode for climate device. target: entity: domain: climate @@ -26,16 +20,12 @@ set_preset_mode: - climate.ClimateEntityFeature.PRESET_MODE fields: preset_mode: - name: Preset mode - description: New value of preset mode. required: true example: "away" selector: text: set_temperature: - name: Set temperature - description: Set target temperature of climate device. target: entity: domain: climate @@ -44,8 +34,6 @@ set_temperature: - climate.ClimateEntityFeature.TARGET_TEMPERATURE_RANGE fields: temperature: - name: Temperature - description: New target temperature for HVAC. filter: supported_features: - climate.ClimateEntityFeature.TARGET_TEMPERATURE @@ -56,8 +44,6 @@ set_temperature: step: 0.1 mode: box target_temp_high: - name: Target temperature high - description: New target high temperature for HVAC. filter: supported_features: - climate.ClimateEntityFeature.TARGET_TEMPERATURE_RANGE @@ -69,8 +55,6 @@ set_temperature: step: 0.1 mode: box target_temp_low: - name: Target temperature low - description: New target low temperature for HVAC. filter: supported_features: - climate.ClimateEntityFeature.TARGET_TEMPERATURE_RANGE @@ -82,29 +66,18 @@ set_temperature: step: 0.1 mode: box hvac_mode: - name: HVAC mode - description: HVAC operation mode to set temperature to. selector: select: options: - - label: "Off" - value: "off" - - label: "Auto" - value: "auto" - - label: "Cool" - value: "cool" - - label: "Dry" - value: "dry" - - label: "Fan Only" - value: "fan_only" - - label: "Heat/Cool" - value: "heat_cool" - - label: "Heat" - value: "heat" - + - "off" + - "auto" + - "cool" + - "dry" + - "fan_only" + - "heat_cool" + - "heat" + translation_key: hvac_mode set_humidity: - name: Set target humidity - description: Set target humidity of climate device. target: entity: domain: climate @@ -112,8 +85,6 @@ set_humidity: - climate.ClimateEntityFeature.TARGET_HUMIDITY fields: humidity: - name: Humidity - description: New target humidity for climate device. required: true selector: number: @@ -122,8 +93,6 @@ set_humidity: unit_of_measurement: "%" set_fan_mode: - name: Set fan mode - description: Set fan operation for climate device. target: entity: domain: climate @@ -131,44 +100,29 @@ set_fan_mode: - climate.ClimateEntityFeature.FAN_MODE fields: fan_mode: - name: Fan mode - description: New value of fan mode. required: true example: "low" selector: text: set_hvac_mode: - name: Set HVAC mode - description: Set HVAC operation mode for climate device. target: entity: domain: climate fields: hvac_mode: - name: HVAC mode - description: New value of operation mode. selector: select: options: - - label: "Off" - value: "off" - - label: "Auto" - value: "auto" - - label: "Cool" - value: "cool" - - label: "Dry" - value: "dry" - - label: "Fan Only" - value: "fan_only" - - label: "Heat/Cool" - value: "heat_cool" - - label: "Heat" - value: "heat" - + - "off" + - "auto" + - "cool" + - "dry" + - "fan_only" + - "heat_cool" + - "heat" + translation_key: hvac_mode set_swing_mode: - name: Set swing mode - description: Set swing operation for climate device. target: entity: domain: climate @@ -176,23 +130,17 @@ set_swing_mode: - climate.ClimateEntityFeature.SWING_MODE fields: swing_mode: - name: Swing mode - description: New value of swing mode. required: true example: "horizontal" selector: text: turn_on: - name: Turn on - description: Turn climate device on. target: entity: domain: climate turn_off: - name: Turn off - description: Turn climate device off. target: entity: domain: climate diff --git a/homeassistant/components/climate/strings.json b/homeassistant/components/climate/strings.json index 8034799a6d0..bfe0f490cda 100644 --- a/homeassistant/components/climate/strings.json +++ b/homeassistant/components/climate/strings.json @@ -28,9 +28,15 @@ "fan_only": "Fan only" }, "state_attributes": { - "aux_heat": { "name": "Aux heat" }, - "current_humidity": { "name": "Current humidity" }, - "current_temperature": { "name": "Current temperature" }, + "aux_heat": { + "name": "Aux heat" + }, + "current_humidity": { + "name": "Current humidity" + }, + "current_temperature": { + "name": "Current temperature" + }, "fan_mode": { "name": "Fan mode", "state": { @@ -49,7 +55,9 @@ "fan_modes": { "name": "Fan modes" }, - "humidity": { "name": "Target humidity" }, + "humidity": { + "name": "Target humidity" + }, "hvac_action": { "name": "Current action", "state": { @@ -65,10 +73,18 @@ "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" }, + "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": { @@ -98,10 +114,123 @@ "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" } + "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" + } + } + } + }, + "services": { + "set_aux_heat": { + "name": "Turn on/off auxiliary heater", + "description": "Turns auxiliary heater on/off.", + "fields": { + "aux_heat": { + "name": "Auxiliary heating", + "description": "New value of auxiliary heater." + } + } + }, + "set_preset_mode": { + "name": "Set preset mode", + "description": "Sets preset mode.", + "fields": { + "preset_mode": { + "name": "Preset mode", + "description": "Preset mode." + } + } + }, + "set_temperature": { + "name": "Set target temperature", + "description": "Sets target temperature.", + "fields": { + "temperature": { + "name": "Temperature", + "description": "Target temperature." + }, + "target_temp_high": { + "name": "Target temperature high", + "description": "High target temperature." + }, + "target_temp_low": { + "name": "Target temperature low", + "description": "Low target temperature." + }, + "hvac_mode": { + "name": "HVAC mode", + "description": "HVAC operation mode." + } + } + }, + "set_humidity": { + "name": "Set target humidity", + "description": "Sets target humidity.", + "fields": { + "humidity": { + "name": "Humidity", + "description": "Target humidity." + } + } + }, + "set_fan_mode": { + "name": "Set fan mode", + "description": "Sets fan operation mode.", + "fields": { + "fan_mode": { + "name": "Fan mode", + "description": "Fan operation mode." + } + } + }, + "set_hvac_mode": { + "name": "Set HVAC mode", + "description": "Sets HVAC operation mode.", + "fields": { + "hvac_mode": { + "name": "HVAC mode", + "description": "HVAC operation mode." + } + } + }, + "set_swing_mode": { + "name": "Set swing mode", + "description": "Sets swing operation mode.", + "fields": { + "swing_mode": { + "name": "Swing mode", + "description": "Swing operation mode." + } + } + }, + "turn_on": { + "name": "Turn on", + "description": "Turns climate device on." + }, + "turn_off": { + "name": "Turn off", + "description": "Turns climate device off." + } + }, + "selector": { + "hvac_mode": { + "options": { + "off": "Off", + "auto": "Auto", + "cool": "Cool", + "dry": "Dry", + "fan_only": "Fan only", + "heat_cool": "Heat/cool", + "heat": "Heat" } } }