When to use quotes on entity_id

I had following bit of automation:

- alias: Vijver lucht uit - triggering temperature
  trigger: 
    - platform: time
      minutes: 0
      seconds: 05
  condition:
    - condition: state                      # Program is not active, and,
      entity_id: input_boolean.pond_active
      state: 'off'
    - condition: template                   # temp
      value_template: '{{ (states("sensor.weather_temperature") | int) > 1 }}'
  action:
    - entity_id: switch.ds1_q2_13
      service: homeassistant.turn_off

and despite input_boolean.pond_active having the value ‘on’ it executed the action. After specifying the entity_id in quotes, it didnt trigger anymore. So I am confused because there are plenty of examples where entity_id is not quoted, but in conditions (https://www.home-assistant.io/docs/scripts/conditions/) they are quoted, so when is quoted required ? In this case they were apparently needed but I have also other cases, is it luck they work without quotes ?

Entity ids never need quotes, something else was wrong with your configuration. I have no idea why some of the examples on that page have quotes around them.

1 Like

Rule 3. You have double quotes inside single quotes here:

value_template: '{{ (states("sensor.weather_temperature") | int) > 1 }}'

Try it the other way round:

value_template: "{{ (states('sensor.weather_temperature') | int) > 1 }}"

As tom mentioned, put the double quotes on the outside. Just as an aside, during a bout of everything crashing after an upgrade I thought I should go through my own code and clean it up. One line at a time I found a good default was to use double quotes on the outside of statements even if there is nothing quoted inside. It seems to work well and also keeps my code consistent.

It’s also the recommended standard…

https://developers.home-assistant.io/docs/en/documentation_standards.html#templates