Hello, I want to know how to make a condition be checked when an automation is triggered. So if my binary sensor 1 goes “off”, I notify telegram on the condition that sensor 2 does not change in the next 30 seconds. I have tried with the for and the telegram notification notifies me when the sensor goes from “on” to “off” state. What I want is that sensor 1 goes “off” wait 30 seconds to verify that sensor two has not changed in 30 seconds.
I think it’s best to wait for version 0.115, which will introduce wait_for trigger, which is exactly what you need. Currently, it would involve some timestamp logic etc…
- id: '1596277325558'
alias: xTest
description: Test only.....
trigger:
- platform: state
entity_id: binary_sensor.movimiento0105_occupancy
to: 'on'
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.xxxx #<- put the second binary sensor here
to: 'on'
timeout: '00:00:30'
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.xxxx #<- put the second binary sensor here
state: 'off'
sequence:
- servie: blalbla #<- put the action you want to take if the binary sensor didn't change
default: []
This triggers when the the first binary_sensor changes to on, it then waits for 30 seconds and if the second binary sensor doesn’t change to on in these 30 seconds, it executes the action, otherwise nothing happens.
I want it to change when sensor 1 goes off, but that doesn’t matter I guess. I have copied your code and the home assistant validates, but when I restart I get the following error in notifications: The following integrations and platforms could not be configured:
- id: '1596277325558'
alias: xTest
description: Test only.....
trigger:
- platform: state
entity_id: binary_sensor.0215
to: 'on'
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.movimiento0105_occupancy #<- put the second binary sensor here
to: 'on'
timeout: '00:00:30'
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.movimiento0105_occupancy #<- put the second binary sensor here
state: 'off'
sequence:
- service: notify.telegram2
data:
message: hola
You forgot the default action at the end and the service part needs to be indeted more, like this:
- id: '1596277325558'
alias: xTest
description: Test only.....
trigger:
- platform: state
entity_id: binary_sensor.0215
to: 'on'
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.movimiento0105_occupancy #<- put the second binary sensor here
to: 'on'
timeout: '00:00:30'
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.movimiento0105_occupancy #<- put the second binary sensor here
state: 'off'
sequence:
- service: notify.telegram2
data:
message: hola
default: []
Tried to serve up ‘/config/www/community/custom-sidebar/custom-sidebar.js’ but it does not exist
I have the same error as before, copying the default line:
14:37:53 – /usr/local/lib/python3.8/site-packages/integrationhelper/logger.py (ERROR)
Invalid config for [automation]: [timeout] is an invalid option for [automation]. Check: automation->timeout. (See /config/configuration.yaml, line 12).
I’m sorry, the indentation for timeout was wrong, try again like this:
- id: '1596277325558'
alias: xTest
description: Test only.....
trigger:
- platform: state
entity_id: binary_sensor.0215
to: 'on'
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.movimiento0105_occupancy #<- put the second binary sensor here
to: 'on'
timeout: '00:00:30'
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.movimiento0105_occupancy #<- put the second binary sensor here
state: 'off'
sequence:
- service: notify.telegram2
data:
message: hola
default: []