Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid service: switch.turn_ #65

Open
stepsolar opened this issue Mar 21, 2024 · 1 comment
Open

invalid service: switch.turn_ #65

stepsolar opened this issue Mar 21, 2024 · 1 comment

Comments

@stepsolar
Copy link

stepsolar commented Mar 21, 2024

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

@stepsolar stepsolar changed the title off mode error invalid service: switch.turn_ Mar 21, 2024
@TNTLarsn
Copy link

- 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' ) }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants