Contents
- Why make your mailbox smart?
- The hardware: two sensors, two jobs
- A motion sensor inside the mailbox, for arrivals
- A contact sensor on the door, for collection
- How does Home Assistant know the mail has arrived?
- Avoiding false alerts when collecting the mail
- The phone notification
- An alert that clears itself
- The mail card on the dashboard
- The door sensor that reported nothing
- My take and my tips
- Conclusion
- FAQ
Opening the mailbox only to find it empty is a waste of time. Mine is 6 to 7 metres (about 20 feet) from the garage door, and I no longer wanted to walk out there just to check whether the mail had come.
For a year now, Home Assistant has been telling me on my phone when the mail carrier has been, and the alert clears itself as soon as someone collects the mail. Here is the complete setup: two sensors for âŹ22 in total (Tapo hub not included), four automations, the notification, the dashboard card, and the failure I had to fix.
Why make your mailbox smart?
A smart mailbox tells you, without going outside, whether the mail has arrived. With Home Assistant, the alert also clears once the mail has been collected, so it always tells the truth.
I had two needs:
- get an alert when mail arrives, on my phone and on the wall-mounted tablet;
- know whether someone has already collected it, so nobody walks out for nothing.
The second point is often overlooked. An alert that stays on screen when the mailbox is empty soon gets ignored.
The hardware: two sensors, two jobs
A single sensor canât cover both needs. I use two, each with its own job.

A motion sensor inside the mailbox, for arrivals
A TP-Link Tapo T100 motion sensor is stuck to the ceiling of the mailbox with the double-sided tape that comes with it. When the mail carrier pushes the mail through the slot, the sensor sees it fall and switches to âmotion detectedâ.
The Tapo T100 doesnât work on its own: it goes through a Tapo hub. Mine is an H500, which also links other Tapo sensors in the house. In Home Assistant, the hub and its sensors come in through the TP-Link Smart Home integration.
The T100 uses 868 MHz radio in Europe and runs on a CR2450 battery. TP-Link rates the battery at two years with 50 detections a day, and gives an operating range of 0 to 40 °C, which winter goes beyond in an outdoor mailbox. In my case, it went through last winter without any trouble.

A contact sensor on the door, for collection
My mailbox is a standard French metal mailbox: a slot at the front, and a door at the back to collect the mail. A Sonoff SNZB-04P contact sensor watches that door: the sensor is stuck inside the mailbox, against the side wall right by the opening, and its magnet on the door. When someone opens the mailbox to take the mail, the magnet moves away from the sensor and Home Assistant knows.
This sensor is Zigbee, connected through ZHA, Home Assistantâs Zigbee integration. It also reports tampering, which I donât use here.


| Sensor | What it detects | My take |
|---|---|---|
| Tapo T100 (âŹ12), inside the mailbox | Mail dropping through the slot | Full signal (3 out of 3) despite the metal box, nothing to tweak. |
| Sonoff SNZB-04P (âŹ10), at the door | The door opening to collect the mail | Weak Zigbee link from the mailbox, I had to move a repeater closer. |
| Tapo H500 hub | Links the T100 to Home Assistant | Required for the T100. It also links other Tapo sensors in my house. |
How does Home Assistant know the mail has arrived?
Home Assistant treats the mail as arrived when the mailbox sensor sees motion for 5 seconds, with no alert already active and no mailbox opening in the last 5 minutes. It then sends the notification and records the time of the delivery.
The automation follows these steps:
- The mailbox sensor switches to âmotion detectedâ and stays there for 5 seconds.
- Home Assistant checks that no mail alert is already active.
- It checks that the mailbox hasnât been opened or marked as collected in the last 5 minutes.
- It records the delivery time, sends the notification to the phone and creates one in Home Assistant.
- It marks the alert as active: while it is, more motion sends nothing.
The mail status lives in helpers, created under Settings, Devices & services, Helpers:
input_boolean.mail_notified: an alert is active;input_boolean.mail_collected: the mail has been collected;input_datetime.mail_arrival: time of the last delivery;input_datetime.mailbox_last_collectionandinput_datetime.mailbox_last_motion: time of the last collection and of the last motion.
Avoiding false alerts when collecting the mail
When you open the mailbox to take the mail, the sensor sees your hand. In Home Assistantâs history, the motion comes 1 to 2 seconds after the door opens, at every collection. Without a safeguard, each collection would trigger a âmail arrivedâ alert.
Hence the 5-minute window: motion less than 5 minutes after the door opens, or after a tap on âcollectedâ, is ignored. Over the last 10 days, the door was opened 4 times with no alert active, and none of those openings triggered a false alert.
The time of the last opening is recorded by an automation instead of being read from the sensor. The Zigbee sensor changes state every time it reconnects, which skewed the calculation.
View YAML code
alias: Mail - Arrival notification
description: >-
Alert when mail drops into the mailbox. Ignores motion in the 5 min after
the mailbox is opened or the mail is collected.
triggers:
- trigger: state
entity_id: binary_sensor.mailbox_motion
to: "on"
for:
seconds: 5
conditions:
- condition: state
entity_id: input_boolean.mail_notified
state: "off"
# Last real opening of the mailbox, recorded by the tracking automation
# (not the sensor's last state change, skewed by its reconnections)
- condition: template
value_template: >-
{{ now().timestamp() - state_attr('input_datetime.mailbox_last_collection', 'timestamp') | float(0) > 300 }}
- condition: template
value_template: >-
{{ (now() - states.input_boolean.mail_collected.last_changed).total_seconds() > 300 }}
actions:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.mail_arrival
data:
datetime: "{{ now().isoformat() }}"
- action: input_boolean.turn_off
target:
entity_id: input_boolean.mail_collected
- action: persistent_notification.create
data:
title: đŹ Mailbox
message: You've got mail!
notification_id: mailbox_notification
- action: notify.mobile_app_my_phone
data:
title: đŹ Mailbox
message: You've got mail!
data:
tag: mailbox_delivery
channel: mail
priority: high
ttl: 0
sticky: true
color: "#1E90FF"
clickAction: /dashboard-mobile/home
- action: input_boolean.turn_on
target:
entity_id: input_boolean.mail_notified
mode: singleThe phone notification
The notification goes to my Android phone through the Home Assistant app. It is set up to be noticed, then to disappear as soon as it no longer applies:
channel: mail: a separate notification channel, so the phoneâs sound and importance settings for this alert donât affect the others;priority: highandttl: 0: according to the app documentation, the notification rings right away, even when the phone has been lying with its screen off for a long time;sticky: true: it doesnât go away when tapped;clickAction: tapping it opens the phone dashboard;tag: mailbox_delivery: a name that lets you clear it later.
I use the same channel and tag approach for my e-bike charging reminder.

An alert that clears itself
The mail counts as collected in three cases:
- the mailboxâs collection door opens;
- someone taps the âMail in the mailboxâ card on the dashboard;
- new motion comes more than 2 minutes after the alert (a fallback, explained below).
Home Assistant then clears the phone notification with the special clear_notification message and the same tag, and removes the one in Home Assistant. In the history, the notification disappears half a second after the door opens.
If nobody collects the mail, the phone notification clears at midnight so it doesnât linger for days. The dashboard card, however, stays visible until someone opens the mailbox or taps the card.
View YAML code
Tracking deliveries and collections:
alias: Mailbox - Mail tracking
description: >-
Records the time of the last motion and of the last collection. The door
opening, or motion more than 2 min after the alert, counts as a collection.
triggers:
- trigger: state
entity_id: binary_sensor.mailbox_motion
to: "on"
id: motion
- trigger: state
entity_id: binary_sensor.mailbox_door
to: "on"
id: door_opened
actions:
- choose:
- conditions:
- condition: trigger
id: motion
sequence:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.mailbox_last_motion
data:
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
- alias: New motion after the alert = mail collected
if:
- condition: state
entity_id: input_boolean.mail_notified
state: "on"
for:
minutes: 2
then:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.mailbox_last_collection
data:
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
- action: input_boolean.turn_on
target:
entity_id: input_boolean.mail_collected
- conditions:
- condition: trigger
id: door_opened
sequence:
- action: input_datetime.set_datetime
target:
entity_id: input_datetime.mailbox_last_collection
data:
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
- action: input_boolean.turn_on
target:
entity_id: input_boolean.mail_collected
mode: queuedClearing the notification on collection:
alias: Mail - Clear notification (collection)
triggers:
- trigger: state
entity_id: binary_sensor.mailbox_door
to: "on"
- trigger: state
entity_id: input_boolean.mail_collected
to: "on"
conditions:
- condition: state
entity_id: input_boolean.mail_notified
state: "on"
actions:
- action: persistent_notification.dismiss
data:
notification_id: mailbox_notification
- action: notify.mobile_app_my_phone
data:
message: clear_notification
data:
tag: mailbox_delivery
- action: input_boolean.turn_off
target:
entity_id: input_boolean.mail_notified
mode: singleMidnight reset:
alias: Mail - Midnight reset
triggers:
- trigger: time
at: "00:00:00"
conditions:
- condition: state
entity_id: input_boolean.mail_notified
state: "on"
actions:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.mail_notified
- action: persistent_notification.dismiss
data:
notification_id: mailbox_notification
- action: notify.mobile_app_my_phone
data:
message: clear_notification
data:
tag: mailbox_delivery
mode: singleThe mail card on the dashboard
On the wall-mounted tablet and on the phone dashboard, a âMail in the mailboxâ card only shows up when mail is waiting. Tapping it marks the mail as collected, which also clears the phone notification.
This card is part of the âto doâ area of my wall-mounted tablet dashboard, where a card only appears when something needs doing. When thereâs no mail, no bin to put out and no open window, a single green line is left: âNothing to reportâ.

On the phone, a second card shows the mailbox status at all times, with the date and time of the last delivery.
View YAML code
Both cards use the Template card from Mushroom, installed through HACS. Styling has been removed.
The card in the âto doâ area:
type: custom:mushroom-template-card
primary: Mail in the mailbox
secondary: Tap once collected
icon: mdi:mailbox-up
icon_color: orange
tap_action:
action: perform-action
perform_action: input_boolean.turn_on
target:
entity_id: input_boolean.mail_collected
visibility:
- condition: state
entity: input_boolean.mail_collected
state: "off"The status card on the phone:
type: custom:mushroom-template-card
primary: >-
{{ 'Mail in the mailbox' if is_state('input_boolean.mail_collected', 'off') else 'Mailbox empty' }}
secondary: >-
Last delivery {{ as_timestamp(states.binary_sensor.mailbox_motion.last_changed, none) | timestamp_custom('%d/%m at %H:%M', true, '-') }}
icon: >-
{{ 'mdi:mailbox-up' if is_state('input_boolean.mail_collected', 'off') else 'mdi:mailbox-outline' }}
icon_color: >-
{{ 'orange' if is_state('input_boolean.mail_collected', 'off') else 'grey' }}
tap_action:
action: perform-action
perform_action: input_boolean.turn_on
target:
entity_id: input_boolean.mail_collected
hold_action:
action: more-info
entity: binary_sensor.mailbox_motionThe door sensor that reported nothing
The failure in this setup came from the Zigbee door sensor. For 10 days, it reported no openings at all: it kept switching between âclosedâ and âunavailableâ, a sign of a link too weak from the metal mailbox, 6 to 7 metres from the house. So the notification never cleared on its own; only the dashboard button worked.
Zigbee uses the 2.4 GHz band, and a battery-powered sensor doesnât relay anything: it depends on the nearest Zigbee router, such as a smart plug or a repeater. The Tapo T100, on 868 MHz, sits in the same mailbox and never had this problem.
I first worked around it in Home Assistant: a second motion more than 2 minutes after the alert counts as a collection, since collecting the mail triggers the sensor. Back then, that second motion came 9 to 12 minutes after the delivery.
Then I fixed the cause: I moved an Aeotec Zigbee repeater next to the garage door, as close to the mailbox as possible. Since then, the sensor reports every opening, with a link quality (LQI) of 156 out of 255. If your Zigbee sensors keep dropping off, repeaters make a real difference: I cover that in my Home Assistant mistakes to avoid.
Limitation: a second delivery
The motion fallback has a flaw. If the mail carrier comes back more than 2 minutes after the first drop, Home Assistant thinks the mail has been collected and clears the alert. This fallback is still in place in my setup.
My take and my tips
After a year with this setup, my verdict is simple: itâs very reliable. Iâve had no missed mail and no false alerts, and the mailbox sensor has never caused a problem, winter included.
Over the last 10 days, which is how long Home Assistant keeps detailed history:
- 3 âmail arrivedâ alerts, each followed by the mailbox being opened;
- mail collected 8, 24 and 47 minutes after the alert;
- notification cleared half a second after each opening;
- 4 openings with no alert active, and no false alerts.
My tips if you want to try it:
- Two sensors, two jobs. One for arrival, one for collection. With only one, the alert doesnât know when to clear.
- Check the radio before you stick anything. Watch the link quality in Home Assistant for a few days: an outdoor mailbox is a tough spot for Zigbee.
- Ignore the motion that follows an opening. Otherwise every collection sends a new alert.
- Make the alert clear itself. A tag and
clear_notificationare enough. A notification that stays up when it shouldnât ends up ignored. - Plan a nightly reset, so one missed collection doesnât block the next dayâs alert.
Conclusion
A smart mailbox with Home Assistant comes down to two sensors and four automations. What makes the difference is not so much detecting the mail as detecting its collection: an alert that clears at the right time stays trustworthy. My original goal is met: I know whether thereâs mail without opening the mailbox.


