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'