R Phone Home: Notifications with pushoverr

[This article was first published on Brian Connelly: r, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

There are a lot of times when it would be great if your computer talked to you. pushoverr allows you to send yourself or your group notifications from R. Instead of compulsively checking the status of a running job, you can just have R tell you when it’s done, if it failed, or what the results are.

To get started, download a Pushover client for your mobile device or desktop. Pushover is free for 7 days, but requires a $4.99 license after that. Once you’ve registered, you’ll get a user key, which looks like uQiRzpo4DXghDmr9QzzfQu27cmVRsG. You can find your user key either in the app’s settings or on Pushover’s website after logging in.

Pushover allows you to create “applications”, which are basically just different channels for your messages. You can also receive messages from “public applications” like GitHub (via a service hook), IFTTT, Zapier, and many others.

Creating Your Application

All that it takes to create an application dedicated to receiving messages from R is to visit the create a new application and enter a few fields. For this demo, I’m going to call it pushoverr (it can be anything you want, though). The other fields are optional, but I’m going to set an icon. The R Logo seems like a natural fit (scaled down to 72 pixels wide, download here). Now, whenever a message arrives, I’ll be able to know at a glance that it came from R.

Creating our Pushover application

Once you’ve agreed to the terms and clicked Create Application, you’ll be taken to the information page for your new application. Here, you can see some plots of the number of messages sent by your app both recently and over a longer period. You can also create subscription codes for your applications, which can allow other people to easily subscribe to notifications for that app. This is really handy for sending notifications to coworkers or even a wider audience. For now, what’s most important is your API Token/Key, which we’ll need to send notifications from this app. For my demo application here, the API token is avgk9kgxjp2e5xqnn3kzutvh43g27k.

pushoverr application information page

Sending Notifications

Now it’s time to start sending some messages. Start up an R session and install pushoverr:

install.packages("pushoverr")

Once that’s completed, we’re ready to let R start talking. Load the pushoverr package, and use the pushover function to craft and send your first message.

library("pushoverr")

pushover(message = "Mr. Watson--come here--I want to see you.")

Since this is your first time, pushover will ask you for your user key and app token. Don’t use mine.

setting pushoverr credentials (screenshot)

If everything worked, you should see a notification on your device very shortly.

our first pushoverr notification arrives (screenshot)

Using other arguments to pushover, you can set other aspects of your message, including sounds, links, and message priorities.

Your user key and app token are now saved for the rest of your session, so you can now send messages without having to enter them. Pushover offers 5 different message priorities, ranging from silent to emergency. Let’s send an emergency priority message, which will re-send every 30 seconds until it is acknowledged on your device.

pushover_emergency(message = "The kittens are awake, and they are ANGRY!")

Notification: The kittens are awake, and they are ANGRY! (screenshot)

Displaying Data on Your Wrist

I previously used Numerous to put Lake Union’s current temperature on my watch, which I scraped using R. It was a great way to know how shocking my daily swim would be. Numerous shut down earlier this year, so I was extremely excited to see that Pushover recently added the ability to push data to smaller screens.

pushoverr can now send several different types of data to your watch. For example, we can quickly display the current water temperature.

water_temp <- 52
update_glance(count = water_temp)

Watch displaying temperature (screenshot)

I won’t be swimming today.

We can also send numeric values as a percent, which is good for displaying progress. There’s also support for small bits of text:

update_glance(text = "hello woRld")

Watch displaying 'hello woRld' (screenshot)

Wrapping Up

Enabling R to send you bits of information can be extremely useful. I’ve used Pushover to do this for a few years, but there are several other alternatives. Pushbullet is a similar service that offers a few additional features, but does not yet have watch support. Dirk Eddelbuettel’s RPushbullet package allows you to interface with Pushbullet from R. You can also send notifications from IFTTT. Check out my previous blog post Connecting R to Everything with IFTTT to see how to send notifications and a whole lot more.

To leave a comment for the author, please follow the link and comment on their blog: Brian Connelly: r.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)