I am creating a script that will add ‘n’ seconds to a timer. I am passing these variables so that I can make use of this script in my automation. But it is not working. Can someone help? Thanks in advance.
alias: Add to Timer
mode: single
icon: mdi:camera-timer
fields:
timername:
description: Timer to Add to
addseconds:
description: Seconds to Add
sequence:
- service: timer.pause
data_template:
entity_id: "{{ timername }}"
- service: timer.start
data_template:
duration: >-
{% set r = "{{ state_attr(timername, 'remaining') ~ '-0000' }}" %} {%
set t = strptime(r, '%H:%M:%S%f%z') %} {{ (as_timestamp(t) + addseconds)
| timestamp_custom('%H:%M:%S', false) }}
entity_id: "{{ timername }}"
Error:
Failed to call service script.add_to_timer. Error rendering data template: ValueError: Template error: strptime got invalid input ‘{{ state_attr(timername, ‘remaining’) ~ ‘-0000’ }}’ when rendering template ‘{% set r = “{{ state_attr(timername, ‘remaining’) ~ ‘-0000’ }}” %} {% set t = strptime(r, ‘%H:%M:%S%f%z’) %} {{ (as_timestamp(t) + addseconds) | timestamp_custom(’%H:%M:%S’, false) }}’ but no default was specified