I’m having a terrible time understanding variables and trigger_variables. The automation should start ramping up a light at turn on time and ramp down the light a user specified period before the turn off time. Blueprint input are then lights on time of day, lights off TOD and the ramp duration in minutes. It is the off TOD offset causing so much grief.
In the variable: section a light off TOD offset is calculated (“lightsOffTODOffset”) and seems correct as printed to the log file. Trouble comes trying to use it as a time trigger. I tried trigger_variables as they were advertised to bridge the variables section with triggers. Here is a subsection of the blueprint:
variables:
lightsOnTOD: !input lightsOnTOD
lightsOffTOD: !input lightsOffTOD
rampUpDownDuration: !input rampUpDownDuration
time_fmt: '%H:%M:%S'
lightsOffTODOffset: '{{ strptime(lightsOffTOD,time_fmt) - timedelta(minutes=rampUpDownDuration) }}'
trigger_variables:
tgrV_lightsOffTODOffset: "{{ lightsOffTODOffset }}" # NULL
# tgrV_lightsOffTODOffset: '15:00:00' # string "15:00:00"
# tgrV_lightsOffTODOffset: lightsOffTODOffset # string "lightsOffTODOffset"
trigger:
- platform: time
at:
- !input lightsOnTOD
- '15:00:00' # works
# - "{{ tgrV_lightsOffTODOffset }}" # error message on blueprints page parsing file
As shown above, this works fine and generates an automation. But I’ve yet to get a trigger_variable based on a variable: .
Should some form of tgrV_lightsOffTODOffset: “{{ lightsOffTODOffset }}” work at all? I thought that was the purpose of trigger_variables in the first place. And in the trigger: section, ditto for - “{{ tgrV_lightsOffTODOffset }}” (or another variation like " - tgrV_lightsOffTODOffset"). Is a more complicated template platform approach the way to go or will it run into the same problems.
I hesitate to use a helper. They seem to need creating outside of the blueprint, which defeats the whole purpose of having everything in one file. One misconception was thinking that variables: were set at automation creation time (after hitting the “Save” button), but they are set when run and I guess triggered, which explains a few NULL values.
Basically, how do I use a value calculated from user input as a trigger?
any help appreciated,
mark