OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) How To: Push notifications for OpenSprinkler

Tagged: 

Viewing 25 posts - 26 through 50 (of 55 total)
  • Author
    Posts
  • #38953

    Pat
    Participant

    Updated with the port variable. Feel free to “upgrade” and try it out 🙂

    I should probably move all of these settings into an external config file to make it easier to keep track of them.

    #38954

    joe
    Participant

    Wow , you are fast!
    I was thinking of a config option too. That way when new versions come out, it would be easier to deploy.

    I am new to python and may try a gamble at this myself. If i get it working ill let you know;)

    #38960

    Pat
    Participant

    I just pushed up to github a rather large update. Broke the script out into a config file, which will make future enhancements a little easier. I also added syslog debugging, which will log messages to /var/log/messages if it’s needed for reference later on.

    I’ve been running the new version for most of today and it’s worked great. Try the new version and let me know if there’s any glitches!

    Also as part of this update, you’ll need to install the Python YAML library. sudo easy_install pyyaml

    https://github.com/drsprite/OpenSprinkler-Push-Notifications

    • This reply was modified 5 years ago by Pat.
    #38963

    joe
    Participant

    No glitches here. But I didn’t have easy_install for some reason.

    I installed it with
    sudo apt-get install python-setuptools

    then i was good to go.

    Thanks for the changes. Wonder what else would be cool to be notified about?

    I looked in the API and maybe the water level after a station runs? Could be helpful to know if the stations run quicker than normal..
    Water level (i.e. % Watering).

    • This reply was modified 5 years ago by joe.
    • This reply was modified 5 years ago by joe.
    #38981

    Chad
    Participant

    FYI

    If you don’t want to use a website to hash, here is what I did on the pi:

    echo -n PASSWORD | md5sum

    #38982

    Chad
    Participant

    I think there might be an error in your readme?

    9. To start the script on startups and reboots, run sudo update-rc.d ospi_notifications defaults

    Shouldn’t it state:

    To start the script on startups and reboots, run sudo update-rc.d ospi-notifications defaults

    Dash instead of underscore between “ospi” and “notifications”???

    #38983

    Chad
    Participant

    I know NOTHING about python, and am just trying to learn as I go. What could you add to to the ospi_push_notifications.py file to send a notification that a zone has stopped? Maybe say “Zone ‘n’ has stopped and ran for x minutes”?

    #38990

    Pat
    Participant

    Great md5 tip, I’ll add it to the README. I’ll also fix my typo, thanks for spotting that!

    With the last update I started to think about “Stop” notifications and put a variable in there as a placeholder to get my mind thinking. I think if I set a variable for the current station that’s on, then if a new station comes on, that means the old one is off and send a notification.

    Something I’m thinking about.

    #39040

    Pat
    Participant

    I just pushed to github a pretty big update for this little script.

    I re-wrote the sprinkler station check so now you can get notifications when the zone starts and stops. I added the water level notification that @jchiar was looking for.

    I added more options to the config file, too. You can now select which notification you want to receive, as well as change the notification message from the config file.

    Added more syslog logging – never know when it’s needed.

    Let me know if you find any bugs!

    https://github.com/drsprite/OpenSprinkler-Push-Notifications

    • This reply was modified 4 years, 12 months ago by Pat.
    • This reply was modified 4 years, 12 months ago by Pat.
    #39049

    joe
    Participant

    Pat, Its working great! thanks Love the update 🙂

    • This reply was modified 4 years, 12 months ago by joe.
    #39052

    Pat
    Participant

    @jchiar Interesting. I’m not seeing this error, and the only way I could replicate it was by messing up the YAML spacing. Once I did that, I see that exact error. I’ve learned that YAML can be picky about it’s spacing.

    For YAML, the first sub-item is 2 spaces, then 2nd subitem is 4 spaces from the left margin.

    There’s 3 things we can try:
    1) Re-download the config.yaml from github. This time we can use wget to get an exact copy.
    Save a copy of your existing config.yaml and run wget https://raw.githubusercontent.com/drsprite/OpenSprinkler-Push-Notifications/master/config.yaml from inside /home/pi

    2) Run this on the command line. It should tell you which line and column is invalid.
    python -c "import yaml; yaml.load( open('config.yaml', 'r'), Loader=yaml.Loader )"

    For example, if there is an extra space in front of “port”, it’ll return expected <block end>, but found '<block mapping start>' in "config.yaml", line 3, column 4

    3) Lastly, paste your config file into this site to validate it. http://www.yamllint.com/
    (You should remove your API keys just in case they track those kinds of things).

    It should tell you whether it’s OK or if it failed, and where it failed.

    • This reply was modified 4 years, 12 months ago by Pat.
    #39055

    Pat
    Participant

    Glad it’s working! Just curious what the fix was?

    I’ll leave those troubleshooting tips up just in case someone needs it in the future.

    #39056

    joe
    Participant

    Was a typo I guess in the file. I just recopied the file and re edited it. Weird

    #39057

    joe
    Participant

    Thanks for the tips though!!

    • This reply was modified 4 years, 12 months ago by joe.
    #39096

    nystrom
    Participant

    I was able to modify the code so that I can use IFTTT Maker channel for notifications. Also, I have it working on OSBo.

    Here is what I added to ospi_push_notifications.py:

    
    # Setup variables from config file
    ....
    iftttEventName = config["push"]["ifttt"]["eventName"]
    iftttUserKey = config["push"]["ifttt"]["userKey"]
    ....
    # Send Push Notification
    ....
            elif (pushService == "ifttt"):
                    url = "https://maker.ifttt.com/trigger/" + iftttEventName + "/with/key/" + iftttUserKey
                    payload = {'value1': event }
                    #print url
                    #print payload
                    ret = requests.post(url, data = payload)
                    syslog.syslog("Notification sent to %s. Message: %s. Return message %s" % (pushService,event,ret))
                    #print ret
    
    .....
    
    

    And I added this to the config.yaml file:

    
    push:
      service: "ifttt" # Acceptable options are "instapush" or "pushover" or "ifttt"
    ......
      ifttt:
        eventName: "YOUR_IFTTT_EVENT_NAME"
        userKey: "YOUR_IFTTT_USER_KEY"
    
    #39097

    joe
    Participant

    Cool. I use iftt also !

    #39098

    Pat
    Participant

    Love IFTTT. Great addition. I’ll add it in! Thanks!

    #39100

    Pat
    Participant

    Works great! Just pushed it up to github, as well as updated the README to include instructions on how to setup the maker channel and add a new recipe for the event.

    https://github.com/drsprite/OpenSprinkler-Push-Notifications

    The beauty with IFTTT is you can do whatever you want with this. Doesn’t have to be a push notification. Could be an SMS, an email. So many options! 🙂

    Here’s the quick push notification recipe I setup:

    • This reply was modified 4 years, 12 months ago by Pat.
    #39119

    nystrom
    Participant

    Thanks for adding the code in. You code was just what I was looking for.

    Here are a couple of additions I thought about adding, but didn’t want my code to deviate too much. Maybe add this to the wish list:

    1 – Allow the station number to be appended into the IFTTT event name (like is done with the event message.) i.e.’EventName{}’ –> ‘EventName1’, ‘EventName2’, … This would allow different IFTTT actions for different stations. I already tested it, and it does work. Just not sure best way to integrate with existing code.

    2 – Retrieve the station names and use them in the event message. Retrieving the names was straight forward, but passing them to the push code was more code deviation. Would be nice to have different replace symbols in the event message to allow different information to be inserted, maybe using regular expression matching and replacement. ( {0} is replaced by station number, {1} is replaced by station name, …) I wrote something, but it is a bit of a hack, as I don’t have much Python experience.

    3 – Turn notifications on for only some stations, some actions. My stations are grouped, so that the same stations always run in sequence. I only care when station 1 starts and station 3 ends, and when station 4 starts and station 6 ends. Maybe some kind of data structure in the config that would allow customizing this on a station by station basis. Config data per station would include ‘Push when turns on’ (y/n), ‘Push when turns off’ (y/n), ‘Station name’, ‘IFTTT “value1” format’, ‘IFTTT event name’, …

    Just some thoughts for adding to the common code.

    Thanks again

    #39122

    Pat
    Participant

    Some good thoughts. I’ll have to see how to include it – but if you’ve been tinkering already and have the code good to go (and working), feel free to do a pull request on github and I can review it and easily merge it in with the script!

    #39125

    Pat
    Participant

    @nystrom I just pushed to Github an update for part of your request #2 – station name from the OSPi (instead of my old “Zone #” notification).

    • This reply was modified 4 years, 12 months ago by Pat.
    #39130

    Pat
    Participant

    For those tracking the script for updates, I just updated it again with some bugfixes to the rain sensor and the email error alerting.

    #39172

    joe
    Participant

    Will give a whirl at new code tomorrow.

    Just wanted to tell you how I am impressed that I was just notified that my sensor detected rain!
    How cool is that?

    #39596

    tom
    Participant

    How about tracking changes to the site configuration, as well? E.g. the water level is set to zero, or whatever?

    #47662

    wifi75
    Participant

    Hello you can write installation step by step?

    • This reply was modified 2 years, 9 months ago by wifi75.
Viewing 25 posts - 26 through 50 (of 55 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) How To: Push notifications for OpenSprinkler