Skip to content

Receive a Pushnotification when someone opens your Mailbox (Postbox)

License

Notifications You must be signed in to change notification settings

MichaMican/mail-alerting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mail-alerting

Receive a Pushnotification when someone opens your Mailbox (Postbox)

Special Thanks

  • @a-mnich
  • @crnnr

What you'll need

  • ESP32
  • Reed switch
  • Resistor (300 Ohm - other resistances should work too though)
  • Raspberry Pi (Zero)
  • Mqtt Broker (can also be installed on the Raspberry Pi)

How to Setup

  1. Replace the code as necessary and described below
  2. Wire up the ESP
  3. Upload MailAlertingClient.ino to ESP
  4. Setup RapberryPi
  5. OPTIONAL: Install Mosquitto MQTT Broker on RasberryPi)
  6. Copy receiverService.py to /home/pi directory
  7. Install pip dependencies
  8. Copy MailboxReceiverService.service to /etc/systemd/system
  9. Make script executable (chmod)
  10. Reload systemd & enable service

Code

  1. Clone the repo
  2. Replace variable values:
    Client/MailAlertingClient.ino
Variable Default Value Description
wifiSSID SSID of your Wifi where MQTT Broker is accessible
wifiPassword Password of your Wifi
MQTT_BROKER_IP IP of your MQTT Broker (If you run the MQTT Broker on the Raspberry Pi this will be the same IP as the Raspberry IP)
MQTT_BROKER_PORT 1883 Port of the MQTT broker.
MQTT_CLIENT_NAME maclient Client name which the ESP will use to publish
ReceiverService/receiverService.py
Variable Default Value Description
MQTT_BROKER_IP IP of your MQTT Broker (If you run the MQTT Broker on the Raspberry Pi this will be the same IP as the Raspberry IP).
MQTT_BROKER_PORT 1883 Port of the MQTT broker.
DEVICES_FOR_NOTIFICATION None V2Ids of Devices, which should receive a notification on Mailbox open. You can target specific devices by setting this to a arry of ids e.g. ['AB12']. The default setting will publish to all Devices.
DEVICES_FOR_IMPLICIT_NOTIFICATION None V2Ids of Devices, which should receive a notification on a implicit Mailbox open. This is send when the receiver Service receives two closed states without an open state in between. You can target specific devices by setting this to a arry of ids e.g. ['AB12']. The default setting will publish to all Devices.
MAILBOX_OPEN_TEXT Mailbox was opened Text which should get pushed to the devices on Mailbox open.
MAILBOX_STATE_MISSED_TEXT Mailbox was opened (explicit open state missed) Text which should get pushed to the devices on implicit Mailbox open. This is send when the receiver Service receives two closed states without an open state in between.
PUSH_NOTIFIER_USER_NAME UserName of your PushNotifier Account
PUSH_NOTIFIER_PASSWORD Password of your PushNotifier Account
PUSH_NOTIFIER_PACKAGE_NAME Packagename of your PushNotifier App
PUSH_NOTIFIER_API_KEY APIKey of your PushNotifier Account

ESP Setup

Dependencies

Wiring

  1. Connect a reed switch to the 3V3 PIN and the G13 (GPIO 13) pin.
  2. Connect the G13 switch with the resistor to any GND (ground) pin.

Raspberry Pi Setup

Dependencies

Raspberry Pi Setup

Install Python dependencies

> pip install paho-mqtt
> pip install pushnotifier

Setup systemd to automatically start the receiverService.py

> sudo chmod 744 MailboxReceiverService.service
> sudo chmod +x MailboxReceiverService.service
> sudo systemctl daemon-reload
> sudo systemctl enable MailboxReceiverService.service
> sudo systemctl start MailboxReceiverService.service

NOTE: To Debug the systemd setup you can use sudo systemctl status MailboxReceiverService.service for the general status and journalctl -e -u MailboxReceiverService for more detailed logs

About

Receive a Pushnotification when someone opens your Mailbox (Postbox)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published