Using Pushover with Electric Imp

Here I will show how to easy be able to use Pushover.net with an Electric Imp.

It can be done a few ways, and be triggered by the device, but in this first example I am only going to show how to interface with the Pushover API.

function pushover(message)
{
  local token = "insert application token";
  local user = "inser user token";
  local priority = 1; // -1 = low, 0 = normal, 1 = high

  local request = http.post("https://api.pushover.net/1/messages.json", {"Content-Type": "application/x-www-form-urlencoded"}, "token=" + token + "&user=" + user + "&message=" + message + "&priority=" + priority);
  local response = request.sendsync();
  server.log("Pushover response: " + response.body);
}
pushover("This message was send from the Electric Imp Agent");

On the front page of Pushover.net (after logging in) you will find your user token. At the bottom of the page you then find a link to create a new application. You will then find the application token under the application you just created.

Inser the two tokens into the function in the agent, “Build and Run” and you should get a message looking something like this.

Screenshot_2014-01-03-23-10-20

2 comments

  • How would you get the code to be triggered from the device? (device code) Here is the example code from the Electric Imp site:

    // Alias the GPIO pin as ‘button’
    button <- hardware.pin1;

    function buttonPress() {
    local state = button.read();
    if (state == 1) {
    // The button is released
    server.log("Release");
    } else {
    // The button is pressed
    server.log("Press");
    }

    }

    // Configure the button to call buttonPress() when the pin's state changes
    button.configure(DIGITAL_IN_PULLUP, buttonPress);

Leave a Reply