Some hardware links on this page are affiliate links. As an Amazon Associate I earn from qualifying purchases. We may earn a commission if you buy through them, at no extra cost to you. See the affiliate disclosure.
A vibration sensor on a door also hears the door closing, a truck outside, and someone walking through. This pack treats a knock as vibration while the contact stays closed, and only after the door has already been still. Opening or closing the door is not a knock. The action is whatever you attach: a phone push, a short chime on a media player, or both.
Entity ids are blueprint inputs. Do not publish which door the contact belongs to.
This is not an open/close alert. Door and window open notify fires when the contact changes. Use that for “it opened,” and this pack for “someone knocked and the door is still shut.”
What problem it solves
You want a knock to reach a phone or a speaker, and you want the alert to stay quiet when the door is simply used.
How it works
For a contact with device_class: door, on is open and off is closed. Fix an inverted sensor before you trust the blueprint.
- Trigger — the vibration binary sensor goes from
offtoon. - Still closed — the contact must already have been
off(closed) for a quiet period (pack default 30 seconds). A door that just shut is ignored, which drops the slam. - Confirm — wait a short beat (pack default 3 seconds) and check the contact again. If it opened, someone came in and the action is skipped. If it is still closed, run the action.
- Action — a notify, a chime script, or both. The message is an input. There is no camera snapshot in this pack.
- Cooldown — a timer (pack default 60 seconds) blocks another alert so a long buzz does not repeat. The timer is the only memory; a restart clears it, which is acceptable for a knock.
An optional condition input can suppress the alert when nobody is home, or when a doorbell mute helper is on.
Hardware notes
- Contact. Any door binary sensor already in Home Assistant, or a Zigbee contact. Mount the magnet so closed is reliable. A flaky contact makes every knock look like an entry.
- Vibration. An SW-420 module on an ESP32 GPIO, published as
device_class: vibration, is the cheap path. The potentiometer sets how hard a hit must be; start sensitive and back off until a knock hits and a passing truck does not. A Zigbee vibration binary sensor works the same in the blueprint if you already have one. Stick the sensor mid-panel, where a knuckle actually lands, not on the hinge. - Power. The SW-420 wants 3.3 V or 5 V and a common ground with the ESP32. It is a digital on/off, not an accelerometer trace. One GPIO is enough.
- Chime. Any media player that can play a short local file. Optional.
Wi-Fi credentials for the ESPHome node stay in secrets.yaml.
Snippet
ESPHome for the vibration module. The GPIO is a substitution.
substitutions:
knock_pin: GPIO4
binary_sensor:
- platform: gpio
pin: ${knock_pin}
name: Door vibration
device_class: vibration
filters:
- delayed_off: 300ms
Blueprint shape. Closed is off on a door contact.
trigger:
- platform: state
entity_id: !input vibration_sensor
from: "off"
to: "on"
condition:
- condition: state
entity_id: !input contact_sensor
state: "off"
for: !input door_still_for
action:
- delay: !input confirm_for
- condition: state
entity_id: !input contact_sensor
state: "off"
- condition: state
entity_id: !input cooldown_timer
state: "idle"
- action: timer.start
target:
entity_id: !input cooldown_timer
data:
duration: !input cooldown_for
- action: notify.send_message
target: !input notify_target
data:
title: Knock
message: Vibration on a door that stayed closed.
Setup outline
- Confirm the contact: door shut is
off, door open ison, in Developer Tools. - Flash the vibration node or pair an existing vibration sensor. Tap the door and confirm a short
on. - Create a timer helper for the cooldown. Import the blueprint and fill vibration, contact, notify target, still-closed time, confirm delay, and cooldown.
- With the door shut and still, knock. You should get one alert after the confirm delay.
- Open the door, shut it, and knock immediately. You should get nothing until the still-closed time has passed. Walk through and confirm the open contact cancels the alert.
Troubleshooting
- Every close alerts. The still-closed time is shorter than the vibration from the latch. Raise it. Thirty seconds is the pack default for a reason.
- Nothing ever alerts. The contact is inverted (
onwhile shut), the vibration pin is the wrong level, or the confirm delay is so long the sensor has already dropped and a later condition fails. Watch both entities while you knock once. - Truck outside alerts. The SW-420 pot is too sensitive, or the sensor is on a hollow panel that rings. Desensitize, and keep the still-closed check.
- Five pushes for one knock. Cooldown is missing, or the vibration sensor stays
onand retriggers.delayed_offon the GPIO plus the cooldown timer fixes that. - Chime plays, no phone push. The notify target is a media player script only. Add the Companion notify as a second action in the blueprint’s action list.
Credits
Based on the community blueprint Door Knock Detection. This write-up is an original overview of vibration plus a closed-door gate, not a paste of that blueprint.