Appreciate the response. That post talks more about the scope and evaluation order across the automation. I’m trying to figure out evaluation order within the variables section (var_3 in the example you linked to).
That said, I wonder if I can hack this together by putting “base” variables in earlier sections and “dependent” variables in areas that post indicates get evaluated later.
The templates should be rendered in order, read from top to bottom, so the way you have them should be fine. Is the error showing up during runs of the automation or at some other time like restart?
You can simplify you templates a little bit using tuple comparison instead of calculating minutes and using the in test instead of 2 separate equality operations.
variables:
is_daytime: "{{ (23,0) > (now().hour,now().minute) > (5,0) }}"
is_outside_camera: "{{ source_camera not in ['familyroom', 'familyroom_pool'] }}"
should_describe: "{{ (not is_daytime) or is_outside_camera }}"
The script variables evaluate incorrectly. Specifically, should_describe evaluates to true even though is_daytime is true and is_outside_camera is false. I see that in the trace, here:
yah just did the same right as you were replying. Also restart HA. It’s working now and the script config matches the order of the script itself. Very odd.
Thank you for the help, and also appreciate the code optimizations!