---
title: "Home Assistant Mailbox Sensor: Get Alerted When the Mail Arrives"
description: "Get a phone alert 📬 when the mail arrives: a Home Assistant mailbox sensor setup with two sensors, a self-clearing notification and a dashboard card."
url: "https://www.the-optimization-guy.com/en/blog/smart-mailbox-sensor-home-assistant/"
lang: "en"
published: "2026-12-04"
---

# My smart mailbox: Home Assistant lets me know when the mail carrier comes

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.

*Image: My mailbox seen through the collection door: the motion sensor on the ceiling, top left, and the contact sensor at the bottom left.*

### 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.

*Image: The Tapo T100 stuck in a corner of the mailbox ceiling with the supplied tape.*

Product: [Tapo T100 Motion Sensor](https://amzn.to/45Sw28P), Paid €12 (affiliate link)

### 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.

*Image: Left, the Sonoff sensor against the side wall, right by the collection door (open here). Right, its magnet, stuck on the door.*

Product: [Sonoff SNZB-04P Contact Sensor](https://www.domadoo.fr/fr/produits-de-domotique/7058-sonoff-capteur-de-porte-ou-fenetre-zigbee-30-snzb-04p.html?domid=129), Paid €10 (affiliate link)

| 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:

1. The mailbox sensor switches to “motion detected” and stays there for 5 seconds.
2. Home Assistant checks that no mail alert is already active.
3. It checks that the mailbox hasn’t been opened or marked as collected in the last 5 minutes.
4. It records the delivery time, sends the notification to the phone and creates one in Home Assistant.
5. 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_collection` and `input_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.

```yaml
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: single
```

## The 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](https://companion.home-assistant.io/docs/notifications/notifications-basic/#notification-channels), so the phone’s sound and importance settings for this alert don’t affect the others;
- `priority: high` and `ttl: 0`: according to the [app documentation](https://companion.home-assistant.io/docs/notifications/critical-notifications/), 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](https://www.the-optimization-guy.com/en/blog/ebike-charging-reminder-home-assistant/).

*Image: The notification on my Android phone. My setup is in French: “Boîte aux lettres” is the ”📬 Mailbox” title and “Du courrier est arrivé !” the “You’ve got mail!” message from the automation above.*

### An alert that clears itself

The mail counts as collected in three cases:

1. the mailbox’s collection door opens;
2. someone taps the “Mail in the mailbox” card on the dashboard;
3. 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`](https://companion.home-assistant.io/docs/notifications/notifications-basic/#clearing) 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.

Tracking deliveries and collections:

```yaml
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: queued
```

Clearing the notification on collection:

```yaml
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: single
```

Midnight reset:

```yaml
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: single
```

## The 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](https://www.the-optimization-guy.com/en/blog/wall-mounted-home-assistant-tablet/), 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”.

*Image: The card in the “to do” area of my wall tablet, in French: “Courrier dans la boîte” is “Mail in the mailbox” and “Toucher une fois récupéré” is “Tap once collected”. It only shows up when mail is waiting.*

On the phone, a second card shows the mailbox status at all times, with the date and time of the last delivery.

Both cards use the Template card from [Mushroom](https://github.com/piitaya/lovelace-mushroom), installed through HACS. Styling has been removed.

The card in the “to do” area:

```yaml
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:

```yaml
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_motion
```

Read also: [Wall-Mounted Home Assistant Tablet: My Complete Setup](https://www.the-optimization-guy.com/en/blog/wall-mounted-home-assistant-tablet/)

## The 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](https://www.the-optimization-guy.com/en/blog/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_notification` are 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.

## FAQ

### Which sensor should I put in my mailbox for Home Assistant?

A motion sensor inside to see the mail arrive, and a contact sensor on the collection door to know it has been taken. In my case, a Tapo T100 (868 MHz, with a Tapo hub) and a Zigbee Sonoff SNZB-04P.

### Does a Zigbee sensor work in an outdoor mailbox?

Yes, but the link can be too weak. My mailbox is 6 to 7 metres from the house, and the Zigbee door sensor reported nothing for 10 days: check the link quality (LQI) in Home Assistant before relying on it.

### Does a metal mailbox stop the sensor from communicating?

Not in my case: both sensors communicate from inside my metal mailbox, and the Tapo T100 keeps full signal. For the Zigbee door sensor, though, I had to move a Zigbee repeater closer to the mailbox.

### How do I avoid an alert when I collect the mail myself?

Ignore motion that follows the mailbox being opened. In my automation, motion less than 5 minutes after an opening or a tap on "collected" triggers nothing.

### Do I need a sensor on the mailbox door?

It isn't required, but it's the most reliable way to know the mail has been collected. Without it, you have to guess the collection, for example from a second motion, and a second delivery can then clear the alert by mistake.

### Does a smart mailbox detect parcels?

Not as such: the sensor sees motion, whatever is dropped into the mailbox. A parcel too big for the slot, left next to it, isn't detected.
