I’m quite sure my code once worked. But it currently does not, I saw errors in the protocol, that delay expects other parameters. I’m not sure if I reverted all changed I did while trying to repair, but anyway. I’d like to know what is wrong.
- delay
(last step in my script - so it works without delay currently) gives a message that
Fehler: offset should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F'
Script to activate state
alias: Licht Zustand aktivieren
description: ""
sequence:
- if:
- condition: template
value_template: "{{ is_state(lampe, 'unavailable') }}"
- condition: template
value_template: "{{ is_state(schalter, 'on') }}"
then:
- sequence:
- action: switch.turn_off
metadata: {}
data_template: {}
target:
entity_id: "{{ schalter }}"
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 500
- action: switch.turn_on
metadata: {}
data_template: {}
target:
entity_id: "{{ schalter }}"
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 250
enabled: true
- if:
- condition: template
value_template: "{{ is_state(schalter, 'off') }}"
then:
- action: switch.turn_on
metadata: {}
data_template: {}
target:
entity_id: "{{ schalter }}"
- action: scene.turn_on
target:
entity_id: >-
{{ 'scene.' ~ liste ~ '_' ~ states('input_select.' ~ liste ~ '_zustand')
}}
data: {}
- delay: "{{ delay }}"
fields:
schalter:
required: true
description: Steuert ZigBee-Licht
default: switch.lichtschalter_flur_kg
lampe:
required: true
default: light.keller_hornbach_baumarkt_ag_viyu_a60_806_rgbw_10011725_light
liste:
default: flur_kg
required: true
delay:
selector:
duration:
enable_millisecond: true
default:
hours: 0
minutes: 0
seconds: 0
milliseconds: 100
mode: queued
max: 10
So my field which I’d like to use is defined as this:
fields:
delay:
selector:
duration:
enable_millisecond: true
default:
hours: 0
minutes: 0
seconds: 0
milliseconds: 100
and giving this field as parameter to the delay as this:
- delay: "{{ delay }}"
gives the error that duration does not expect a time, it expects a string.
I mean, OK, I can sure filter it somehow to create a string.
But why is the delay function not expecting a time duration to wait as parameter, but a string which can be converted to a duration? Why did it work before? Which is the correct and most elegant way to do this delay?
