hass-template-climate
hass-template-climate copied to clipboard
invalid service: switch.turn_
The problem
I need your help, I wrote this code and it all works but when I turn off homeassistant it gives me an error, but the shutdown actually happens. How can I modify the code? Thank you
What version of Template Climate has the issue?
No response
What version of Home Assistant are you running?
No response
What type of installation are you running?
None
Example YAML snippet
climate:
- platform: climate_template
name: Termostato Sauna
unique_id: termo_Sauna
modes:
- "off"
- "heat"
- "dry"
min_temp: 40
max_temp: 100
min_humidity: 0
max_humidity: 100
temp_step: 1.0
# sonda temperatura sauna
current_temperature_template: "{{ states('sensor.spa_sonda_temp_sauna') }}"
# sonda umidità sauna
current_humidity_template: "{{ states('number.spa_setpoint_umid_biosauna') }}" #per il momento metto il setpoint dopo metto la sonda di umidità
# setpoit temperatura Sauna
target_temperature_template: "{{states ('number.spa_setpoint_temp_sauna') }}"
# setpoit umidità Sauna
target_humidity_template: "{{states ('number.spa_setpoint_umid_biosauna') }}"
set_temperature:
- service: number.set_value
entity_id: number.spa_setpoint_temp_sauna
data:
value: "{{ temperature }}"
set_humidity:
- service: number.set_value
entity_id: number.spa_setpoint_umid_biosauna
data:
value: "{{ humidity }}"
hvac_action_template: "{{ state('switch.spa_termo_sauna_auto_off' ) }}"
set_hvac_mode:
- service: switch.turn_{{ 'off' if hvac_mode == 'off' else 'on' }}
entity_id: switch.spa_termo_sauna_auto_off
# - service: select.select_option
# data:
# entity_id: select.spa_sell_biosauna_sauna
# option: "{{ 'Biosauna' if hvac_mode == 'dry' else 'Sauna' if hvac_mode == 'heat' else 'off' if hvac_mode == 'off'}}"
- service: switch.turn_{{ 'off' if hvac_mode == 'dry' else 'on' if hvac_mode == 'heat' }}
entity_id: switch.spa_sel_on_sauna_off_biosauna
Anything in the logs that might be useful for us?
Registratore: homeassistant.helpers.template Fonte: helpers/template.py:2377 Prima occorrenza: 13:34:09 (3 occorrenze) Ultima registrazione: 13:34:22
Template variable error: 'state' is undefined when rendering '{{ state('switch.tatano_state' ) }}' Template variable error: 'state' is undefined when rendering '{{ state('switch.spa_termo_sauna_auto_off' ) }}'
Registratore: homeassistant.helpers.script.termostato_sauna Fonte: helpers/script.py:1805 Prima occorrenza: 13:34:24 (1 occorrenze) Ultima registrazione: 13:34:24
Termostato Sauna: Error executing script. Error for call_service at pos 2: Template rendered invalid service: switch.turn_
Additional information
No response
- service: {{ 'switch.turn_' + ('off' if hvac_mode == 'off' else 'on') }}
change
{{ state('switch.tatano_state' ) }}
to
{{ states('switch.tatano_state' ) }}
Also change
{{ state('switch.spa_termo_sauna_auto_off' ) }}
to
{{ states('switch.spa_termo_sauna_auto_off' ) }}