Hi,
I’m trying to clean my code a little and trying to figure out when to use single and double quotes.
When I finally thought I understood I saw this two examples:
automation:
alias: "Exterior Lighting on when dark outside"
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
# Can be a positive or negative number
below: -4.0
action:
service: switch.turn_on
entity_id: switch.exterior_lighting
In the above example we open and close with double quotes and use single quotes inside.
This is what I believed was the correct way.
Then I checked the documentation for condtions:
condition:
condition: and # 'twilight' condition: dusk and dawn, in typical locations
conditions:
- condition: template
value_template: '{{ state_attr("sun.sun", "elevation") < 0 }}'
- condition: template
value_template: '{{ state_attr("sun.sun", "elevation") > -6 }}'
In this example, we open with single quotes and use double quotes inside?!?
What did I miss? Is there a reason for this since we evaluate the elevation already inside the template?
Or is the condition documentation wrong?
Both seems to work but I would like to understand and use the correct way.
Thanks and best regards