Send notification - here: special conditions question

Hello out there !

Today, another question to the community…

I have a garage door, which is equipped with a contact sensor, as well as with a camera. The contact sensor detects opening and closing of the garage door, as usual, the camera can transmit motion to home assistant. I have setup a notification for both, opening and closing of the garage door. As sometimes, however, the contact sensor detects opening or closing, even without anything is happening in reality, I recieve a notification for these “false alarms”… So, for the garage door opening, I configured as a condition for the notification, that after the contact sensor detects open, the camera must detect a motion of the garage door as well, or no notification will be sent.

And now there comes my request: For the opposite, the closing, I want to configure that a notification is send, when the contact sensor detects close and the camera detected motion BEFORE… Just setting up contact sensor close with condition camera motion on is not leading to a result, as if the contact sensor detects close, there is no motion anymore of the garage door. Setting the camera condition to “no motion” will lead to false alarms about a closed garage door again, as of course, if the contact sensor detects close, there is no motion on camera as well… So I need to get somehow the condition that there WAS motion on camera BEFORE contact sensor detects closed to make sure, there will be no false alarms anymore…

Can you help on how to set this up ? - Thank in advance !!

Cheers
Marco

One approach to this is to use the last_changed attribute of the motion sensor.

The basic method would be a template condition comparing the difference between current time and the time of the last change of the sensor to a specific interval:

condition:
  - condition: template
    value_template: '{{now() - states.sensor.YOUR_MOTION_SENSOR.last_changed < timedelta(minutes=2) }}'

You will probably need to adjust the timedelta value based on your actual sensors and closing automation.

Thank you, this saved my day ! :slight_smile:

1 Like