July 26, 2019 at 4:56 am #61870
I’m a relative new user of the OpenSprinkler software, I bought a Opensprinkler (clone) board (TSPI) and build a complete garden irrigation system around it.
I also use the OSPI software and build metal housing for the raspberry PI (2B+) and I have of all kind of domotica systems in and around my home.
This topic is a small how-to about using OSPI and the great Node-Red software.
Node-Red is a platform for NodeJS. with a really nice graphic way of programming and I use it for a “1001” things. But mainly for interfacing with all the different API’s on my system.
I don’t going to bother you with that part. I will give you a example how you can use the OS API with Node-Red and a way to let that respond to physical buttons (mounted on the housing).
So let’s get started
1. First, you need to setup Node-RED. There a many how-to’s on the web for that. It’s packaged for the most (linux) environments so that should be easy.
2. Second you need a working OpenSprinkler software 😊.
The goal is to interact with the OS API calls to set the sprinkler-zones to work or start / stop a program. I used a rotary 6 pos. switch that I connected to 6 GPIO pins on the raspberry.
I also setup a (big) button on GPOI pin 37 that I programmed to give the “stop all activity” command.
1. 6-position rotary switch
2. Latching “start” switch, inline connected with the rotary switch
3. 19mm latching button (cancel function)
4. LCD display, 20×4 characters
5. Button to restart raspberry PI (not documented in this how-to)
So when you draw this in a schema you will get something like this:
So now the software part in NODE-RED.
Open a flow canvas and import my attached demo flow. I put it on pastbin because for some reason this forum will empty the topic..
I made quite some documentation in al the nodes and function so I think it will be clear.
There a 5 “area’s “ in the flow, I will try to explain them a bit:
1. This are the general variables for the flow, a MD5 password hash function and the URL for posting to the OpenSprinkler API.
2. The GPIO raspberry PI buttons, also 6 “software buttons” that simulate the press on a button (so you can test it without actualy pressing the fysical button on the case)
4. An http websocket node, this makes all the GET calls to the OS API.
5. The functions for (optional) LCD display, I used a common 20×4 LCD display with i2c interface, costs about 8 euro (10 dollar).
I hope this will give you all a few good examples how you easily can interact with the OS API. I made more flows with Node-red on it, it interacts with my home-assistant server, MQTT message bus, telegram chats, IFFT and more 😊
Feel free to ask any question on this examples or other points.
@Ray, really pleased with the API function, although it’s a bit tricky because it’s a GET API and not a restfull (push/pull) API so getting the right status when some thing changed is a bit frustrating but overall very nice opensource software!
- You must be logged in to reply to this topic.