Send Pushover Notification when MotionEyeOS Boots

Now I’ve got a few MotionEyeOS based cameras around the house I wanted an easier way to know when they were rebooted and also have a link on my phone to make it easier to access the camera feed. I’ve got the excellent Pushover app on my phone so I decided to get MotionEyeOS to send Pushover notifications whenever it restarted. The notification states what the IP address is and provides a handy link to click.

The notifications look like this :

with an individual notification looking like :

Pushover Service

To use Pushover you need to sign up for an account on and install the mobile app. The app costs money but is a one off cost and one I was happy to pay. Within your user account dashboard you will find a user “token”. New “applications” can be created and each one will have a unique “API token”. I created an application named “MotionEyeOS” and used it’s token for both my cameras.

You can use Pushover for other projects and it’s compatible with any programming language that can call a web URL.

Port Forwarding

The notification provides the IP address of the network as seen from outside. Router “port forwarding” can be used to direct requests from outside the network to the specific Pi running MotionEyeOS. Your network will only have one external IP address but many devices and using ports allows to communicate with each one.

In the examples in this post I am using port 40000 and my router is re-directing this to the Pi on my network. The router redirects all incoming traffic to port 40000 to the internal IP address of my Pi (e.g. using the port number defined in as the “HTTP Port” in the MotionEyeOS admin “Expert Settings”. Internally I use to access my Garden camera but externally I use

So the notification includes a link to “”. By setting up multiple rules you can access different MotionEyeOS installations on the same network. Just give them each a different port. A second camera could use 40001 and the router would just redirect to appropriate internal IP address ( e.g. .

If you are unsure how to setup your router Google “port forwarding netgear r8000” but replace “netgear r8000” with the brand and model of your router. Someone, somewhere will have written a guide to explain it.

Bash Script –

To get MotionEyeOS to run some custom commands at boot, you can create the file /data/etc/ and fill it up with your commands. This is an existing feature can be used for lots of other purposes.


sleep 10

ip=$(curl -s

python /data/ $location $ip $user $token > /var/log/pushover &

There’s no need to add a shebang (i.e. #!/bin/sh) at the beginning of the file and there is no need to make it executable.

You can find a copy of in my BitBucket repository. It can be downloaded directly to your Pi using:


Make sure this script ends up in the /data/etc directory.

Note : It is critical you change the “user” and “token” variables with your own user and api tokens. If you don’t do this it will not work.

Python Script –

When the system boots the “” script will wait ten seconds, obtain the internet IP address using the service and then run the “” script. The “” script should be placed in the /data/ directory.

import httplib, urllib
import sys

if len(sys.argv)==5:

  # Get 4 arguments passed to this script
  mytitle=sys.argv[1]+" camera rebooted"
  mymessage="Your "+sys.argv[1]+" camera has just rebooted"


  conn = httplib.HTTPSConnection("")
  conn.request("POST", "/1/messages.json",
      "token": mytoken,      # Pushover app token
      "user": myuser,        # Pushover user token
      "html": "1",           # 1 for HTML, 0 to disable
      "title": mytitle,      # Title of message
      "message": mymessage,  # Message (HTML if required)
      "url": myip,           # Link to include in message
      "url_title": myip,     # Text for link
      "sound": "cosmic",     # Sound played on receiving device
    }), { "Content-type": "application/x-www-form-urlencoded" })

This script sends the tokens, title, message and URL to include in the message to Pushover. If successful the notification will be sent to your phone and will appear in the app.


Any “print” statements in the Python script will be directed to the “/var/log/pushover” file. You can view the contents of this file when the system has booted using :

cat /var/log/pushover

At the moment it just prints the notification title but you could enhance the Python script to print more detailed information and maybe a time-stamp.


In order for this mechanism to work everything needs to be correctly setup. If you get one step wrong it will probably not work at all. Here are some things to check :

  • Your MotionEyeOS system should be up and running and the web interface available on your local network.
  • You should have an active Pushover account with the mobile app installed.
  • Within Pushover you should have an application created which will give you an “API Token/Key”.
  • The script should exist in /data/
  • should match the script in my BitBucket repository exactly.
  • The script should exist  in /data/etc/
  • should match the script in my BitBucket repository exactly but should use your Pushover keys and Port number.
  • Your router should map the incoming port number used in to the “HTML Port” defined in MotionEyeOS “Expert Settings”.