Conditions and templates

struggling with an automation condition that is a template. there have been many iterations, the code below is just one of my failures

originally in a non-template version {{ states(‘climate.kitchen’) == “heat” }} is true

but

              - if:
                  - condition: not
                    conditions:
                      - condition: template
                        value_template: "{{ states(trigger.entity_id) == "heat" }}"

gives a “template value should be a string” error

what silly mistake am I making ?

You have double-quotes inside double-quotes

2 Likes

Depending on the rest of the code, you may be able to use trigger.to_state.state rather than states(trigger.entity_id), which is probably a bit more efficient (although you’ll still need to fix the quoting).

If you post the entire code, I’m sure you’ll get lots of help to clean it up and optimise it.

1 Like