Raspberry Pi Push Notifications Code
Notifications to phone from Raspberry PI for GPIO connected devices
Brought to you by:
fred07734
File | Date | Author | Commit |
---|---|---|---|
README.txt | 2021-08-03 |
![]() |
[a1082a] Initial commit |
install_notify.sh | 2021-08-03 |
![]() |
[a1082a] Initial commit |
notify.desktop | 2021-08-03 |
![]() |
[a1082a] Initial commit |
notify.service | 2021-08-03 |
![]() |
[a1082a] Initial commit |
notify.svg | 2021-08-03 |
![]() |
[a1082a] Initial commit |
notify_config_phn_not.py | 2021-08-03 |
![]() |
[a1082a] Initial commit |
notify_config_txt_eml.py | 2021-08-03 |
![]() |
[a1082a] Initial commit |
notify_phn_not.py | 2021-08-03 |
![]() |
[a1082a] Initial commit |
notify_txt_eml.py | 2021-08-03 |
![]() |
[a1082a] Initial commit |
uninstall_notify.sh | 2021-08-03 |
![]() |
[a1082a] Initial commit |
PASSWORD PROBLEMS IN THE TEXT/EMAIL NOTIFICATION OPTION: The sending email password is an "app password" or "third-party password", which is frequently not the same password used from a Webmail interface. To obtain an "app password" or "third-party password" go to: Gmail: https://support.google.com/accounts/answer/185833?hl=en Microsoft Outlook/Hotmail: https://support.microsoft.com/en-us/office/add-your-outlook-com-account-to-another-mail-app-or-smart-device-73f3b178-0009-41ae-aab1-87b80fa94970 Yahoo: https://my.help.yahoo.com/kb/account/generate-third-party-passwords-sln15241.html -------------------------------------------------------------------------------------- PURPOSE: This software is for delivering notifications to remote devices such as smartphones and tablets from a Raspberry Pi when the Raspberry Pi is connected through its GPIO pins to a device which holds a relay or electronic switch temporarily closed when activated. An example of such as device is a Dakota Alert break beam sensor. -------------------------------------------------------------------------------------- INSTALLATION: Download the .tgz file to the /home/pi directory and extract the files using the following command in a terminal window: tar -xvf push_notifications_v0.01.tgz This will create a directory call "push_notifications". In the terminal window change to that directory: cd push_notifications Run the installation script: ./install_notify.sh -------------------------------------------------------------------------------------- INSTALLATION OPTIONS: -> Phone Notifications via Pushover (http://pushover.net): Advantages: - Timely delivery of notifications - Reliable - Can deliver notifications to many devices at the same time - Can select the notification sound (including a user-customized sound) - Can set the priority of the notification on the receiving devices Disadvantages: - For personal use requires a one time payment of US$5.00 for each device type (Android and iPhone/iPad), business users must pay US$5.00 monthly -> Text Message Notifications: Advantages: - Usually timely delivery of notifications, but not guaranteed - Usually reliable delivery of notifications, but not guaranteed - No cost Disadvantages: - Wireless carriers tend to block notification messages as spam, particularly if sent to two phone numbers - Only available in countries with wireless carriers who allow text messages to be sent from email accounts -> Email Message Notification: Advantages - Reliable delivery of notifications - No cost - Not blocked by spam filters Disadvantages - Email service providers and email clients use IMAP to retrieve email messages, thus there is potentially a long polling delay of many minutes introduced. The exception is using a Microsoft Outlook email account with the official Microsoft Outlook email client, in which case EWS is used and notifications are delivered in a timely manner. -------------------------------------------------------------------------------------- UNINSTALLATION: Open a terminal window and change to the push_notifications directory: cd push_notifications Run the uninstallation script: ./uninstall_notify.sh -------------------------------------------------------------------------------------- REQUIREMENTS 1. A Raspberry Pi running the Raspberry Pi OS (Raspbian) 2. The Python scripts are written using Python 3. 3. When using the Pushover notification option, the following Python libraries are required: time, os, io, tkinter, logging, sys, RPi,GPIO, http.client, urllib 4. When using the text message/email message notification option, the following Python libraries are required: time, os, io, tkinter, cryptography.fernet, RPi,GPIO, smtplib, logging, sys -------------------------------------------------------------------------------------- USAGE: Start (Raspberry Pi icon) -> Accessories -> Push Notifications Press Configure button and acknowledge the error dialog box if running for the first time Enter configuration options Press Save button Press Start Service button Press Exit button -------------------------------------------------------------------------------------- NOTE WHEN CONFIGURING THE TEXT/EMAIL NOTIFICATION OPTION: The configuration dialog box supports sending text messages to the top three wireless carriers in the U.S. and Canada. To ensure this is visible, ensure the Raspberry Pi locale is set properly. Start (Raspberry Pi icon) -> Preferences -> Raspberry Pi Configuration -> Locale -> Country If not in the U.S. or Canada or if in the U.S. or Canada and using a carrier other than the top three, select the email option and enter the email address for your phone. This is in the format phone_number@carrier_server. You'll will need to look up the carrier server name for your wireless carrier on the Web or call your wireless carrier. -------------------------------------------------------------------------------------- ERROR LOG: Error messages from the notification service are logged to: /home/pi/push_notifications/notify.log -------------------------------------------------------------------------------------- RASPBERRY PI INTERFACE 1. The GPIO pin number in the Configuration dialog box is the BCM (Broadcom SOC Channel) number, not the board number. These are the numbers shown in green when using the "pinout" command from a terminal on the Raspberry Pi. 2. The GPIO pin specified is configured by the software in with an internal PULLDOWN resistor. When connecting the device to the Raspberry Pi, use a "PULLDOWN" configuration. 3. There are various ways to connect the device to the GPIO pins on the Raspberry Pi. An ultra safe way to do it which doesn't risk burning out the Raspberry Pi is to use an external resistor: Board Pin 1 (3.3V) -> device electronic switch -> 1k resistor -> GPIO Pin 17 The above is for a Raspberry Pi Model 3B+ V1.3. Board pin layouts are different for different Raspberry Pi models. Use the "pinout" command in a terminal window to determine a 3.3V GPIO pin. The connections between the Raspberry Pi and the device can be made with a terminal block, an example of which is: https://www.mouser.com/ProductDetail/TE-Connectivity/1776293-3?qs=bdENzIhz2rnQs8%2FFiCGMHQ%3D%3D There are ways to connect the Raspberry Pi without an external resistor which can be found with a Web search. 4. The device should hold the relay or electronic switch for at least around a second. -------------------------------------------------------------------------------------- LIMITATIONS: 1. Password encryption method is two-way.