(c) Pat O'Brien poblabs@github.com - http://github.com/poblabs Please read LICENSE for licensing info
This is a Python script that will check the OpenSprinkler API for running sprinkler zones (or stations). If a station is running, it will send you a push notification. It also will check to see if the rain sensor has been activated and send a notification for that event as well.
- Sign up for Instapush at www.instapush.im
- Create a new App on Instapush's website with these settings:
- Title:
message
- Tracker:
message
- Push message:
{message}
- Click Basic Info on your newly created app and save the Application ID and the Application Secret.
- Install the Instapush app on your device. The app is basic and is only needed to receive the push notification.
- Sign up for Pushover at http://pushover.net
- Create a new app called
OpenSprinkler
(or whatever you'd like it to be called) - Install the app on your device to receive push notifications.
- Create your maker channel and get your secret key. https://ifttt.com/maker
- Add the secret key, and your event name to the
config.yaml
. I chose my event name to beOpenSprinkler
- Create a new recipe with the following info. You can tailor it to suite your needs, but for this example:
- Trigger channel: Maker
1. Receive a web request
2. Event name:
OpenSprinkler
- That: 1. This is where you can use "iOS Notification" or "Android Notification" or "Email" or "SMS". Whatever you'd like to do.
- Complete the action field and create the recipe.
1. For the Notification field, I simply chose
{{EventName}}: {{Value1}}
. 2. An example that this would display:OpenSprinkler: Zone 1 is now active.
- First, make sure you have the required Python libraries.
- Requests:
sudo easy_install requests
- PyYAML:
sudo easy_install pyyaml
- Copy the
ospi_push_notifications.py
andconfig.yaml
files to/home/pi
chmod 755 /home/pi/ospi_push_notifications.py
- Edit config.yaml and update the items located within.
- Special Note: Your OSPi API password needs to be MD5 hashed. You can create this on the command line. SSH and log into the Pi. Then run:
1.
echo -n hello | md5sum
. 2. For example, "hello" is your OpenSprinkler password and it converts to 5d41402abc4b2a76b9719d911017c592. You would enter"5d41402abc4b2a76b9719d911017c592"
into theconfig.yaml
- Also, if the config file has
{}
for a notification message, this is what will be used for the dynamic value for that notification. 1. For example,start: "Zone {} is now active"
, will send the notification"Zone 1 is now active"
. 2. You must keep the{}
present in that notification message for the dynamic info to be sent through notification. - You can run
sudo python /home/pi/ospi_push_notifications.py
and manually start a station from OpenSprinkler's web page to see if you get a push notification. - Stop running the script by pressing
CTRL+C
if you receive a notification, and continue to install it as a service so it'll run on reboots. - Copy the service script
ospi-notifications
to/etc/init.d
sudo chmod +x /etc/init.d/ospi-notifications
- To start the script on startups and reboots, run
sudo update-rc.d ospi-notifications defaults
- To manually start the service,
sudo service ospi-notifications start
- Other commands you can run are
sudo service ospi-notifications stop | restart | status
- Now that the script is running as a background service, run a zone manually from your phone or the OpenSprinkler web page to see if you get a push notification.
First, make sure you have the required Python libraries. See Script Configuration above.
Then, if for some reason things aren't working, you can check your syslog. Typically this is at /var/log/messages
.
Depending on where the script failed, this should provide some information. Lastly, you can check the init.d log
for the notifications script located at /var/log/ospi-notifications
.
Otherwise check the permissions on the /etc/init.d/ospi-notifications
script as well as the /home/pi/ospi_push_notifications.py
script.