but what I don’t understand is why it works when I set these two lines to 0. So I don’t configure the time delay?
The original idea was that every time the status of the trigger changes, the Choose is used to compare whether it is on or off and then triggers a different action accordingly.
First of all. There is no delay.
It’s a for.
Delay means something happens now, and delay something in to the future.
For means something happens now, but the past [seconds / minutes / hours] something had a specific state.
So you trigger on the change but there is no way the state can have been the same for any period of time.
So does my code
EDIT:
This is also a possible code
id: '1732351519835'
alias: Fensterkontakt
description: ''
triggers:
- trigger: state
entity_id:
- input_boolean.fensterkontakt
for:
seconds: 20
conditions: []
actions:
- choose:
- conditions:
- condition: state
entity_id: input_boolean.fensterkontakt
state: 'on'
for:
hours: 0
minutes: 0
seconds: 10
sequence:
- action: mqtt.publish
metadata: {}
data:
qos: '0'
topic: testmessage
payload: >-
Windows is more than 10s open
- conditions:
- condition: state
entity_id: input_boolean.fensterkontakt
state: 'off'
for:
hours: 0
minutes: 0
seconds: 20
sequence:
- action: mqtt.publish
metadata: {}
data:
qos: '0'
topic: testmessage
payload: >-
Windows is more than 20s closed
mode: restart
This will only trigger when the state has been something for 20 seconds which means it works for both possibilities.
But that makes the “on” part delayed by 10 seconds, you could add another state trigger with for 10 seconds but that just makes things messy in my opnion.
Thanks for the explanation regarding the delay and what the times are all about.
I’ve only been with HA for two weeks. So I still have to get to know all the subtleties.
What I didn’t like about your solution was that I now always have to wait the maximum time (you wrote that too).
For the sake of clarity, I have now helped myself by simply duplicating the contact and parameterizing the appropriate state query and then the time directly here. I have no longer parameterized the time in the Choose application.
id: '1732351519835'
alias: Fensterkontakt
description: ''
triggers:
- trigger: state
entity_id:
- input_boolean.fensterkontakt
for:
hours: 0
minutes: 0
seconds: 10
to: 'on'
- trigger: state
entity_id:
- input_boolean.fensterkontakt
for:
hours: 0
minutes: 0
seconds: 20
to: 'off'
So the solution is at least practicable and comprehensible for me :).