Controlling climate from input select

Tags: #<Tag:0x00007f78027b8910> #<Tag:0x00007f78027b87f8>

I like to minimalize my climate ui and made a setup with a custom slider (for setting temperature) and an input select element (for selecting presets) grouped together with a lovelance custom fold-entity-row. See example below:

Schermafdruk%20van%202019-08-18%2017-07-54

From the input select element, I want to set the climate preset, but one of the options will be ‘off’ which also changes the hvac mode to off. This is my automation so far:

- id: '825223522' 
  alias: Toon                              
  initial_state: true
  hide_entity: false
  trigger:
  - platform: state
    entity_id:
    - input_select.toon_preset
  action:
  - service: climate.set_hvac_mode
    entity_id: climate.toon_thermostaat
    data_template:
      hvac_mode: >
        {% if is_state("input_select.toon_preset", "Uit") %}
          'off'
        {% else %}
          'heat'
        {% endif %}
  - service: climate.set_preset_mode
    entity_id: climate.toon_thermostaat
    data_template:
      preset_mode: >
        {% if is_state("input_select.toon_preset", "Thuis") %}
          'home'
        {% elif is_state("input_select.toon_preset", "Comfort") %}
          'comfort'
        {% elif is_state("input_select.toon_preset", "Slapen") %}
          'sleep'
        {% else %}
          'away'
        {% endif %}

When I test the data templates by pasting them in the dev / template section in HA they will give the desired result. However, it wouldn’t set the climate object. When I try to set the climate object with a non template value It works like that:

  - service: climate.set_preset_mode
    entity_id: climate.toon_thermostaat
    data_template:
      preset_mode: 'sleep'

What am I doing wrong?

Remove the quotes around the mode names…

- id: '825223522' 
  alias: Toon                              
  initial_state: true
  hide_entity: false
  trigger:
  - platform: state
    entity_id:
    - input_select.toon_preset
  action:
  - service: climate.set_hvac_mode
    entity_id: climate.toon_thermostaat
    data_template:
      hvac_mode: >
        {% if is_state("input_select.toon_preset", "Uit") %}
          off
        {% else %}
          heat
        {% endif %}
  - service: climate.set_preset_mode
    entity_id: climate.toon_thermostaat
    data_template:
      preset_mode: >
        {% if is_state("input_select.toon_preset", "Thuis") %}
          home
        {% elif is_state("input_select.toon_preset", "Comfort") %}
          comfort
        {% elif is_state("input_select.toon_preset", "Slapen") %}
          sleep
        {% else %}
          away
        {% endif %}

How simple… and it works! Tank you very much

1 Like

Hi,
I’ve been much trying to do the same with my honnywell eco-home thermostats and failed. Would you be so kind to post your configuration.yaml and the working code in automation? and I assume your entity is “climate.toon_thermostaat” right?
Thanks

sorry, havenot seen your message in time. Do you still need something?

I dont know for @lkeays, but I would like to see your configuration for the lovelace card and how you have setup the automations. I am using a Toon thermostat too, and trying to figure out a nice way to display it together with other entities, and I like the way you have build it. :slight_smile:

I’m in the middle of reconfiguring it all - since the evo home (Honeywell) released a new service around this.
Official Honeywell evohome/Round Thermostat integration (EU-only).
I didn’t use lovelace - I used hadashboard which makes it possible to use a tablet to dispay it all.

I am using a rooted toon (https://github.com/cyberjunky/home-assistant-toon_climate) and defined it in configuraion.yaml like:

climate:
  - platform: toon_climate
    name: Toon thermostaat
    host: 10.0.0.5
    port: 10080

Next I defined a custom input slider like this:

input_number:
  toon_temperature:
    name: Verwarming
    initial: 18
    min: 10
    max: 30
    step: 0.5

And a input select element:

input_select:
  toon_preset:
    name: Toon programma
    options:
      - Thuis
      - Comfort
      - Slapen
      - Afwezig
      - Uit
    icon: mdi:clock-outline

The I needed a variable (see https://github.com/rogro82/hass-variables)

variable:
  update_toon:
    value: 'true'

Then I created these automations:

# Update toon preset and hvac from input select
- id: '825223522' 
  alias: set_toon_preset                             
  initial_state: true
  hide_entity: false
  trigger:
  - platform: state
    entity_id:
    - input_select.toon_preset
  condition:
  - condition: state
    entity_id: variable.update_toon
    state: 'true'
  action:
  - service: climate.set_hvac_mode
    entity_id: climate.toon_thermostaat
    data_template:
      hvac_mode: >
        {% if is_state("input_select.toon_preset", "Uit") %}
          off
        {% else %}
          heat
        {% endif %}
  - service: climate.set_preset_mode
    entity_id: climate.toon_thermostaat
    data_template:
      preset_mode: >
        {% if is_state("input_select.toon_preset", "Thuis") %}
          home
        {% elif is_state("input_select.toon_preset", "Comfort") %}
          comfort
        {% elif is_state("input_select.toon_preset", "Slapen") %}
          sleep
        {% else %}
          away
        {% endif %}
  - service: input_number.set_value
    data_template:
      entity_id: input_number.toon_temperature
      value: "{{ states.climate.toon_thermostaat.attributes.temperature }}"
# Update toon temperature from numeric slider
- id: '82522352576534' 
  alias: set_toon_temperature                            
  initial_state: true
  hide_entity: false
  trigger:
  - platform: state
    entity_id:
    - input_number.toon_temperature
  condition:
  - condition: state
    entity_id: variable.update_toon
    state: 'true'
  - condition: template
    value_template: "{{ (states.climate.toon_thermostaat.attributes.temperature |float) != (states.input_number.toon_temperature.state | float) }}"
  action:
  - service: climate.set_temperature
    data_template:
      entity_id: climate.toon_thermostaat
      temperature: "{{ states.input_number.toon_temperature.state }}"
# Update UI when toon has changed states
- id: '822327643' 
  alias: sync_preset from toon                              
  initial_state: true
  hide_entity: false
  trigger:
  - platform: state
    entity_id:
    - climate.toon_thermostaat
  action:
  - service: variable.set_variable
    data:
      variable: 'update_toon'
      value: 'false'
  - service: script.turn_on
    entity_id: script.toon_preset_update

Finally, I stitch it all togegether using this automation script:

'toon_preset_update':
  alias: toon_preset_update
  sequence: 

  - service: variable.set_variable
    data:
      variable: 'update_toon'
      value: 'false'
  - service: input_select.select_option
    data_template:
      entity_id: input_select.toon_preset
      option: >
        {% if states.climate.toon_thermostaat.attributes.preset_mode == 'home' %}
          Thuis
        {% elif states.climate.toon_thermostaat.attributes.preset_mode == 'comfort' %}
          Comfort
        {% elif states.climate.toon_thermostaat.attributes.preset_mode == 'sleep'  %}
          Slapen
        {% elif states.climate.toon_thermostaat.attributes.preset_mode == 'away'  %}
          Afwezig
        {% endif %}
  - delay: 00:00:01
  - service: input_number.set_value
    data_template:
      entity_id: input_number.toon_temperature
      value: "{{ states.climate.toon_thermostaat.attributes.temperature }}"
  - service: variable.set_variable
    data:
      variable: 'update_toon'
      value: 'true'