I’d like to know if there is any way to create a script and make sure that it is “static”?
For example:
I have my script where I am lowering a IKEA blind to a specified value and then wait for x seconds and then raise the blind again…
Now I want it to be like if I start the script and it executes to the delay and I then executes the same script again, I want the old runtime to just be terminated and the new runtime to continue as normal…
bathroom_blind:
description: Open or close the blind for x minutes
sequence:
- data:
position: 57
entity_id: cover.blind
service: cover.set_cover_position
- data:
duration: '{{ hours }}:{{ minutes }}:{{ seconds }}'
entity_id: timer.bathroom_timer
service: timer.start
- data:
position: 100
entity_id: cover.blind
service: cover.set_cover_position
But now I get error in the developer log…
Close bathroom blind short: Error executing script. Invalid data for call_service at pos 1: offset {{ hours }}:{{ minutes }}:{{ seconds }} should be format ‘HH:MM’ or ‘HH:MM:SS’ for dictionary value @ data[‘duration’
duration: contains a template so change data: to data_template:
If you leave it as data: then it doesn’t attempt to evaluate the template and simply passes it verbatim which is what the error message is complaining about:
Invalid data for call_service at pos 1: offset {{ hours }}:{{ minutes }}:{{ seconds }}
There are two problems with this. First, it doesn’t solve the original problem. If the automation is triggered while the script is running it won’t start over. Second, starting a timer doesn’t cause a delay in the script between the two cover operations. Basically it will lower the cover, start a timer, and then immediately raise the cover. I don’t think that’s what you want. Try this: