Preventing False Triggers in Mailbox Automation

Hey everyone,

I wanted to share my recent experience with setting up an automation for my mailbox sensor. It’s been a bit of a rollercoaster, but I think I’ve finally got it sorted out!

So, I have an ESPHome sensor connected to my mailbox, which is mounted on the fence to keep mail carriers from entering our property. The sensor works by detecting when the mailbox slot opens, signaling that mail has been delivered. This setup worked perfectly for a while, but recently, I started receiving an overwhelming number of notifications—over 500 in a single night! It was quite the shock.

After some investigation, I realized that the sensor was becoming ‘unavailable’ periodically, likely due to cold weather conditions (-5°C). This unavailability was causing false triggers, leading to the excessive notifications. Additionally, even when the sensor was available, it was triggering multiple times unnecessarily.

I tried several approaches to resolve this. First, I adjusted the sensor’s position to ensure more stable readings. Then, I looked into the automation settings to see if I could add some constraints. I discovered that using a time-based constraint could help prevent multiple notifications within a short period.

Here’s the automation I ended up with:

yaml
automation:

  • alias: ‘[NOT] Briefkasten’
    trigger:
    • platform: state
      entity_id: binary_sensor.briefkasten
      from: ‘on’
      to: ‘off’
      condition:
    • condition: state
      entity_id: input_boolean.notification_lock
      state: ‘off’
      action:
    • service: notify.wir_alle
      data:
      title: ‘:outbox_tray:
      message: ‘Bitte Briefkasten leeren :)’
    • service: toggle
      entity_id: input_boolean.notification_lock
    • delay: ‘00:30:00’
    • service: toggle
      entity_id: input_boolean.notification_lock

This setup uses an input_boolean entity called notification_lock to ensure that only one notification is sent every 30 minutes. When the sensor triggers, it checks if notification_lock is off. If it is, the notification is sent, and notification_lock is toggled to on. After 30 minutes, notification_lock is toggled back to off, allowing the next notification.

This solution has significantly reduced the number of false notifications I receive. I’m now only getting one notification per delivery, which is exactly what I wanted.

If anyone has other tips or alternative methods for preventing false triggers, I’d love to hear them! Let’s help each other create more reliable automations.

Cheers,
[Your Name]