Struggling with YAML and templates

YAML and templates are not my cup of tea…

I have struggled for two days with an expression in a script that fails and I can’t get it right. It looks like this:

  - service: '{ %if is_state(''input_boolean.prio_solar'',''on'') and is_state(''sensor.sun_power'',''off'') %} climate.turn_off {%else%} climate.turn_on {%endif%}'
      entity_id: climate.pool

I get the following error:

Actions: Service { %if is_state(‘input_boolean.prio_solar’,‘on’) and is_state(‘sensor.sun_power’,‘off’) %} climate.turn_off {%else%} climate.turn_on {%endif%} does not match format . for dictionary value @ data[2][‘service’]

The template works fine. It returns climate.turn_off or climate.turn_on. But in the service context something is wrong.

Any help on this is appreciated.

1 Like

{% if not { %if.


- service: climate.turn_{{ 'off' if is_state('input_boolean.prio_solar','on') and is_state('sensor.sun_power','off') else 'on' }}
      entity_id: climate.pool

Reverse the on and off.

Yeah, I saw and deleted mine :shushing_face:

Me too and then noticed so had you. :smile:

Go ahead and undo your deletion.

1 Like

Thanks guys! Stupid thing as always…