I’m not sure what logic I’m missing for my automation triggers, conditions, and actions to all properly see the value of a variable set at the top level of the automation…
I’m working on my HVAC automation, and I’m trying to set the target temps once as variables at the beginning of the automation, then reference them later on. Here’s the full YAML in a Gist.
Based on my reading of Passing Variables to Scripts and Variable Scopes, setting variables at the “top” level should make it visible throughout the automation. I’m only setting the value once, then referencing it throughout, not trying to alter the values or anything.
I thought I had it all squared away, but when I try to run it, I get Error: Template rendered invalid entity IDs:
in a few spots, for example:
action: script.upstairs_heat_schedule
data:
variables:
upstairs_am_heat_target: '{{ upstairs_am_heat_target }}'
upstairs_night_target: '{{ upstairs_night_target }}'
I try this logic in Developer Tools > Template Editor, and get an undefined error.
I tried with data:variables:
variables:
upstairs_night_target: 65
upstairs_am_heat_target: 72
action: script.upstairs_heat_schedule
data:
variables:
upstairs_am_heat_target: '{{ upstairs_am_heat_target }}'
upstairs_night_target: '{{ upstairs_night_target }}'
'upstairs_night_target' is undefined
And I tried with just data:
variables:
upstairs_night_target: 65
upstairs_am_heat_target: 72
action: script.upstairs_heat_schedule
data:
upstairs_am_heat_target: '{{ upstairs_am_heat_target }}'
upstairs_night_target: '{{ upstairs_night_target }}'
'upstairs_night_target' is undefined
I just confirmed that all my Scripts have Fields defined, and got this error in the Trace:
Executed: September 28, 2024 at 01:15:55
Error: Template rendered invalid entity IDs:
Result:
params:
domain: script
service: upstairs_heat_schedule
service_data:
variables:
upstairs_am_heat_target: 72
upstairs_night_target: 65
target: {}
running_script: true
child_id:
domain: script
item_id: upstairs_heat_schedule
run_id: 1e5c2e8bf75b9fd03b4321a2a352e3c0
So some part of the action knows the values I’m trying to pass in, but it’s still throwing that error.
Here’s the trace JSON.
The trace also shows the same error in the choose logic, even though it does appear to be evaluating the relative temp correctly, as well as getting the variable values to send on the script.