Sorry if this has been asked before, please do point me in that direction.
I am trying to setup an automation for a notification on a sensor at the moment and it works fine, the problem is I sometimes get false notifications because it’s delayed in getting a result.
Is there any way to do 2 checks over 30 seconds and if they are both the same then notify?
Yes. It helps if you actually share the automation when asking your question so we can show how. But to give you the idea here’s one way as an example:
This one waits 30 seconds then checks the state of the trigger entity id again, if it is not in the correct state nothing happens:
trigger:
- platform: state
entity_id: binary_sensor.foobar
from: "off"
to: "on"
action:
- delay: 30
- condition: state
entity_id: binary_sensor.foobar
state: "on"
- service: notify...etc
And another way that checks for two triggers within 30 seconds, the notification only sends if the two triggers occur within 30 seconds of each other:
trigger:
- platform: state
entity_id: binary_sensor.foobar
from: "off"
to: "on"
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.foobar
from: "off"
to: "on"
timeout:
seconds: 30
continue_on_timeout: false
- service: notify...etc
Note in this second example the state of the binary sensor has to go off → on (1st trigger) → off → on (2nd trigger) within 30 seconds. If you only get one trigger (e.g. the state stays on the whole 30 seconds) nothing happens.