Platform: climate_template -> hvac_mode issue

Hi there, I’m Dennis, using HA for a couple of weeks now, so pretty a newbee. Forum searches helped me a lot to get my Instance working as I want it - but now I’m stuck.

I got climate_template working - almost. When choosing the hvac_mode, selection of modes works fine, only mode “off” is not working. As far as I tested it, the script is not invoked when choosing “off”. Any help apreciated.

configuration.yaml

 - platform: climate_template
    name: schlafzimmer_klimaanlage
    unique_id: "schlafzimmer_klimaanlage"
    current_temperature_template: "{{ states('sensor.temp_schlafzimmer') | float }}"
    target_temperature_template: "{{ states('input_number.schlafzimmer_target_temperature') | float }}"
    hvac_mode_template: "{{ states('input_select.schlafzimmer_hvac_mode') }}"
    fan_mode_template: "{{ states('input_select.schlafzimmer_fan_mode') }}"
    modes:
      - "off"
      - "cool"
      - "heat"
    fan_modes:
      - "low"
      - "medium"
      - "high"
      - "auto"
    min_temp: 16
    max_temp: 30
    set_temperature:
      service: script.set_schlafzimmer_klimaanlage_temperature
      data_template:
        temperature: "{{ temperature }}"
    set_hvac_mode:
      - service: script.set_schlafzimmer_klimaanlage_mode
        data_template:
          hvac_mode: "{{ hvac_mode }}"
    set_fan_mode:
      service: script.set_schlafzimmer_klimaanlage_fan_mode
      data_template:
        fan_mode: "{{ fan_mode }}"

# Input for target temperature
input_number:
  schlafzimmer_target_temperature:
    name: "Target Temperature"
    initial: 22
    min: 16
    max: 30
    step: 1

# Input select for HVAC mode
input_select:
  schlafzimmer_hvac_mode:
    name: "HVAC Mode"
    options:
      - "off"
      - "cool"
      - "heat"
    initial: "off"

  schlafzimmer_fan_mode:
    name: "Fan Mode"
    options:
      - "low"
      - "medium"
      - "high"
      - "auto"
    initial: "auto"

# Input texts for storing IR codes
input_text:
  schlafzimmer_klimaanlage_off:
    name: "Off"
    initial: "Turn off"
  schlafzimmer_klimaanlage_on:
    name: "On"
    initial: "Turn on"  
  schlafzimmer_klimaanlage_cool:
    name: "Cool"
    initial: "cool"
  schlafzimmer_klimaanlage_heat:
    name: "Heat"
    initial: "heat"
  schlafzimmer_klimaanlage_dry:
    name: "Dry"
    initial: "dry"
  schlafzimmer_klimaanlage_fan_only:
    name: "Fan Only"
    initial: "fan"
  schlafzimmer_klimaanlage_fan_low:
    name: "Fan Low"
    initial: "low"
  schlafzimmer_klimaanlage_fan_medium:
    name: "Fan Medium"
    initial: "medium"
  schlafzimmer_klimaanlage_fan_high:
    name: "Fan High"
    initial: "high"
  schlafzimmer_klimaanlage_fan_max:
    name: "Fan Max"
    initial: "max"
  schlafzimmer_klimaanlage_fan_auto:
    name: "Fan Auto"
    initial: "auto"

scripts:

set_schlafzimmer_klimaanlage_temperature:
  sequence:
  - service: remote.send_command
    metadata: {}
    data:
      device: Mitsubishi_Climate
      command: cool_temp_{{ states('input_number.schlafzimmer_target_temperature')
        | int }}
    target:
      entity_id: remote.universal_remote_1
set_schlafzimmer_klimaanlage_mode:
  sequence:
  - service: remote.send_command
    metadata: {}
    data:
      device: Mitsubishi_Climate
      command: "{% if hvac_mode == 'cool' %}\n  {{ states('input_text.schlafzimmer_klimaanlage_cool')
        }}\n{% elif hvac_mode == 'heat' %}\n  {{ states('input_text.schlafzimmer_klimaanlage_heat')
        }}\n{% elif hvac_mode == 'dry' %}\n  {{ states('input_text.schlafzimmer_klimaanlage_dry')
        }}\n{% elif hvac_mode == 'fan_only' %}\n  {{ states('input_text.schlafzimmer_klimaanlage_fan_only')
        }}\n{% elif hvac_mode == 'off' %}\n  {{ states('input_text.schlafzimmer_klimaanlage_off')
        }}\n{% endif %}"
    target:
      entity_id: remote.universal_remote_1
  - service: climate.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: climate.schlafzimmer_klimaanlage
set_schlafzimmer_klimaanlage_fan_mode:
  sequence:
  - service: remote.send_command
    metadata: {}
    data:
      device: Mitsubishi_Climate
      command: "{% if fan_mode == 'low' %} \n {{ states('input_text.schlafzimmer_klimaanlage_fan_low')
        }}\n{% elif fan_mode == 'medium' %} \n {{ states('input_text.schlafzimmer_klimaanlage_fan_medium')
        }}\n{% elif fan_mode == 'high' %} \n {{ states('input_text.schlafzimmer_klimaanlage_fan_high')
        }} \n{% elif fan_mode == 'max' %} \n {{ states('input_text.schlafzimmer_klimaanlage_fan_max')
        }} \n{% elif fan_mode == 'auto' %} \n {{ states('input_text.schlafzimmer_klimaanlage_fan_auto')
        }}\n{% endif %}"
    target:
      entity_id: remote.universal_remote_1

It looks like you are running a climate.turn_on service call after the mode select “off” service call to the remote. If it is needed for other modes to function properly you should include a condition so it is not run following an “off” mode call.

set_schlafzimmer_klimaanlage_mode:
  sequence:
  - service: remote.send_command
    metadata: {}
    data:
      device: Mitsubishi_Climate
      command: |
        {% set source_ent = 'input_text.schlafzimmer_klimaanlage_' ~ hvac_mode | slugify %}
        {{ states(source_ent) }}
    target:
      entity_id: remote.universal_remote_1
  - condition: template
    value_template: "{{ hvac_mode != 'off' }}"
  - service: climate.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: climate.schlafzimmer_klimaanlage

It is a fragment from testing. If it is there, beofre or after the remote.send_command is not changing anything