Get notified via IFTTT or Pushbullet when OpenWRT router has started

Using IFTTT’s Maker channel, I could setup a Web Request receiver or if you prefer a simpler method, you could use Pushbullet. Then I configured my OpenWRT router to post to the receiver on startup.

Motivation

I wanted to know how often my router reboots. Using OpenWRT router, I could configure my router to do something on startup. i.e. calling a web endpoint. With that, I could post a message to IFTTT via its Maker channel or post a message to Pushbullet API. I will explain the setup for both but and the choice is yours.

IFTTT Maker

If you have not heard of IFTTT before. IFTTT stands for If-This-Then-That. In a nutshell, it chains a condition to an action.

The IFTTT Maker channel enables the creation of a HTTPS Web Request receiver. This receiver is secured by an authentication key so that others cannot post to it. Multiple receivers can be created with each for capturing a specific event. Each event can optionally include up to 3 values.

I am assuming that you can figure out how to signup for an account IFTTT and activate the Maker channel. Then you may want to follow these simple steps:

  1. Click on My Recipes.
  2. Click on Create a Recipe.
  3. Choose Trigger Channel: Maker.
  4. Click on Receive a web request.
  5. Give a meaningful Event Name: OpenWRT_started. I recommend replacing spaces with underscore or else you will need to substitute space with %20 later.
  6. Choose Action Channel: IF Notifications.
  7. In the Notification field, enter: {{EventName}} {{Value1}}.

To make a web request from OpenWRT, you must have curl and ca-certificates installed.

opkg update
opkg install curl
opkg install ca-certificates

Once you have the above installed, try out the Maker Web Request endpoint:

curl -X POST --data-binary '{value1":"'"$(date)"'"}' https://maker.ifttt.com/trigger/OpenWRT_started/with/key/<key>

Be sure to replace <key> with your Maker key.

The output from the command above is:

Congratulations! You've fired the OpenWRT_started event

Check the Recipe Log and you should see Personal Recipe triggered. You should be receiving a notification pushed to your phone in a minute if you have IF by IFTTT installed.

Pushbullet

If you prefer Pushbullet, go to Settings > Account > Access Tokens. Click on Create Access Token. Copy that token.

To post a message to Pushbullet from OpenWRT, you will need curl and ca-certificates installed. Scroll up for the instructions.

Then post a message to Pushbullet using:

curl --header 'Access-Token: <Access_Token>' \
     --header 'Content-Type: application/json' \
     --data-binary '{"body":"'"$(date)"'","title":"OpenWRT started","type":"note"}' \
     --request POST \
     https://api.pushbullet.com/v2/pushes

Be sure to replace <Access_Token> with your access token created earlier.

You should be receiving a notification via Pushbullet almost immediately.

Calling IFTTT/Pushbullet on OpenWRT startup

Via OpenWRT LuCI, navigate to System > Startup. Scroll to the bottom and add the the full curl ... line into Local Startup placing it above exit 0. You may want to include a delay until internet connection is available before calling this command. i.e.:

# Wait until Internet connection is available
for i in {1..60}; do ping -c1 -W1 8.8.8.8 &> /dev/null && break; done

# Replace this line with the full curl command to IFTTT/Pushbullet
curl ...

exit 0

Finally, reboot your router to test it out.

Support Me

If this post helped you, would you buy me a cup of tea/coffee?