RPushbullet

RPushbullet is an R client for the wonderful Pushbullet messaging / notification system.

So what is Pushbullet?

Pushbullet is an awesome (and free) little service that acts as a message broker. You sign up, and get a key to use the API. You then install the "app" on your smartphone or Chrome browser (and obtain a device id for of these). You can also query your account with the pbDevices() function to retrieve these ids.

Presto. Now you can send messages between them by invoking pbPost().

Programmatic Access to Pushbullet

Pushbullet also exposes an API which we use here. You can send a (text) note, a link, an image, an address, a file... They appear near instaneously (ie much faster than email would) and immediately "do the right thing". A link opens the page in the browser, images are displayed, addresses are mapped on Google Maps etc pp.

So an obvious use case is to end that long simulation and have a summary chart pushed -- so when you're hanging on the couch or in the bar you get results right there and then.

Access Control for RPushbullet

Upon startup, the package attempts to read a file 'rpushbullet.json' from your home directory. As the extension suggests, the file is in JSON format and immediately converted to a list stored inside an environment accessible to the package. The JSON file should contain a variable 'key' for the API key, as well as a variable 'devices' with one or more device keys.

One quick way to create such a file is to revert the fromJSON() call done when the file is read and do something like

cat(RJSONSIO::toJSON(list(key="..your key here..", devices=c("..device a..", "..device b.."))))

where the values for the list elements key and devices should be, respectively, your API key and one or more device ids. There are optional fields names and defaultdevice as well.

Alternatively, you can also set these values as option() elements in your R startup files, or simply pass them as function arguments (but that last method is really not ideal for scripted use where you may accidentally expose them). These option are all documented in the main package help page.

Example

library(RPushbullet)
pbPost("note", "A simple title", "A message\nWith a second line")

More examples are in the documentation. There are also two short blog posts by Karl Broman: the first discusses notifications from R, and the second one shows a neat trick to invoke RPushbullet in R error condition handlers).

But what about Pushover.net / notifyR ?

Pushover is of course a very similar idea, but (was at the time I looked into this) iOS only whereas I am an Android user. Also, their phone app costs money, which is also a little less cool. So I never looked much into the notifyR package using this service.

On the other hand, Pushbullet usage and apps are free. Pushbullet supports Android and iOS (and browsers and messaging-to-email). That works for me.

But if the Pushover service and app work for you, cool -- I once met its author here in Chicago, and he sure is a nice chap.

Cool. So where does RPushbullet live?

The RPushbullet package is on CRAN from where you can install it in the usual way. The sources are available via GitHub.

License

RPushbullet is licensed under the GPL (version 2 or later).

Initially created: Wed Jun 3 18:06:25 CDT 2014
Last modified: Wed Oct 29 09:23:25 CDT 2014