Monday, July 2, 2018
Push notifications from Raspberry Pi
Push notifications from Raspberry Pi
Often its useful to just receive information from a Raspberry Pi. Surely Yowsup could be nice, but you need a phone card and also its not a simple system to use.
Setting and using Whatsapp with Yowsup can be a nightmare and sometimes it seems a bit unreliable. I do not know if its a Yousup issue or maybe from how I use the libraries (but I found other Yowsup users with similar problems).
If you just need to receive information from the RPi, without sending them, the solution could be using push notifications. These are messages sent to your smart device. The device can be configured to inform you of the incoming message as soon as this is received.
If you just need to receive information from the RPi, without sending them, the solution could be using push notifications. These are messages sent to your smart device. The device can be configured to inform you of the incoming message as soon as this is received.
I searched a lot for different ways to get info from my RPi. One of the best systems I found seems to be Pushover.
First of all I have to say that this service is NOT free (Im not affiliated with them). Anyway its quite reliable and it doesnt cost too much as for less than $5/os (but first week is free to try) you have a lifetime service!
I specified cost for os as this service has an os based fee. You pay to use it on an operating system (eg.IOs or Android) and you can receive notifications on all of your device with that os installed.
Refer to their faq for more info about this.
What I like from Pushover.net is the ability to configure several different applications, each one with its own icon and that can send push notifications to the device(s) you like.
For example, you can have Pushover app installed on both the smartphone and the tablet, but you can choose to send the notification to just one of them or both.
Of course, using push notifications means that you just need an internet connection on the RPi and no phone card at all.
When you sign in at Pushover site, you get a user code that will be used on all of your applications. For every application that you create, you will receive an additional code.
Both these codes must be specified to make you application work.
Lets see an example:
import httplib, urllib
conn = httplib.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
urllib.urlencode({
"token": "this_is_the_application_code",
"user": "this_is_the_user_code",
"message": "3D printing is ended",
}), { "Content-type": "application/x-www-form-urlencoded" })
conn.getresponse()
This is the script Im using to notify that a 3D printing has ended correctly (without my codes of course). As you can see its extremely simple! To use it, I specified in the OctoPrint configuration to call this script in the PrintDone event.
This is what happens on my iPhone:



As you can see, when you open the Pushover app, the app icon is shown beside the notification.
You can also specify a link inside the message that can be opened from the receiving device, if you need it.
The script above has been made with Python, but it can be used with almost every language you can think of. Just take a look at the Pushover.net site for a full list and examples.
As this service is managed from a remote server, you can just forget your script after finished typing and testing them. No updates needed, so much less hassle for us.
This is just a small overview of this nice notification system. Ive been quite satisfied of it and I think it really worths the price.
This is what happens on my iPhone:



As you can see, when you open the Pushover app, the app icon is shown beside the notification.
You can also specify a link inside the message that can be opened from the receiving device, if you need it.
The script above has been made with Python, but it can be used with almost every language you can think of. Just take a look at the Pushover.net site for a full list and examples.
As this service is managed from a remote server, you can just forget your script after finished typing and testing them. No updates needed, so much less hassle for us.
This is just a small overview of this nice notification system. Ive been quite satisfied of it and I think it really worths the price.