Door knock notifications on sliding door

I have not seen any information in this thread that indicates that to be true.

The sensor knows the door has been closed but also sees the contact sensor off while the accelerometer is on for a split second. Therefore it needs to see if it has recently changed rather than how long off but this recent change has to come outside. Thereā€™s one more step to this cause the boolean will still start at the same time as the contact. There was a work around for this but I canā€™t remember and canā€™t find the other post. Iā€™ll post it when I find just for informational purposes.

binary_sensor.back_door_sensor_contact is a binary_sensor that indicates when the door is open or closed. Do you believe it does something else?

My understanding of the challenge is that the accelerometer triggers moments before the contact sensor changes state. Therefore the automation is triggered not only when thereā€™s knocking but when the door is simply opened.

I found it. Now I just have to make the syntax match HASS.

Upon reviewing the requirements, try this version. It triggers when thereā€™s motion detected for at least 2 seconds (knocking) then checks if the door has been closed (off) for at least 10 seconds.

alias: Back door knocking
trigger:
  - platform: state
    entity_id: binary_sensor.back_door_sensor_accelerometer
    to: 'on'
    for: '00:00:02'
condition:
  - condition: state
    entity_id: binary_sensor.back_door_sensor_contact
    to: 'off'
    for: '00:00:10'
action:
  - service: notify.notify
    data:
      message: Knocking at the back door. Do the dogs need to come in?

If you open the door, motion will trigger the automation but the hope is that the minimum 2 seconds will provide enough time for the contact sensor to report its new status (open == on) so that the condition will evaluate to false and prevent the action from executing.

That will probably work because the accelerometer stays on for a few seconds. This would negate the need for boolean. Iā€™ll give it a go.

It worked!!! Thank you both for your time!

1 Like

The webcore example appears to be relying on delays (wait) and a variableā€™s state (loosely equivalent to using an input_boolean or an input_text). Basically, itā€™s attempting to overcome the timing issue between when the accelerometer and contact sensor report their states.

We could duplicate that behavior exactly the same way in Home Assistant but Iā€™m hoping we can leverage other techniques to get the same result but without employing multiple automations and additional entities.

I still called to the devices, rather than the state. Itā€™s funny how these 2 seem redundant.

alias: Back door knocking
description: ''
trigger:
  - type: moving
    platform: device
    device_id: 347070566aaf666b13ee61816a14a5aa
    entity_id: binary_sensor.back_door_sensor_accelerometer
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 2
condition:
  - type: is_not_open
    condition: device
    device_id: 347070566aaf666b13ee61816a14a5aa
    entity_id: binary_sensor.back_door_sensor_contact
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 10
action:
  - service: notify.notify
    data:
      message: Knocking at the back door. Do the dogs need to come in?
mode: parallel
max: 10

I just didnā€™t want to change them both to states, haha

The example you have uses Device Triggers which is indicative that they were created using the Automation Editor. A Device Trigger contains information that is impractical for a user to define manually (like that long-winded device_id) and was designed for use by the Automation Editor.

The equivalent of a Device Trigger is a State Trigger (whose existence predates Device Triggers by several years) and is comparably easy to create manually (i.e. typing text in an editor).

Glad to hear it.

Please consider marking my post (the previous one containing the functional example) with the Solution tag. It will automatically place a check-mark next to the topicā€™s title which signals to other users that this topic has an accepted solution. In addition, it will place a link beneath your first post that leads to the Solution post. All of this helps other users find answers to similar questions.

Yes, I had done so already. I imagine others migrating may find this useful. Thanks again. I jumped ship when I had 3 consecutive days of delayed automations and am loving this so much better.

1 Like