OSBee Wifi Sprinkler Controller

Ever since I started playing with Home Automation on my to do list has been to sort out the Irrigation system and automate that.  We have a fairly straight forward 3 zone configuration for front garden, rear garden and lawns. Currently these are controlled by battery powered timer valves.

They work (other than the occasional issue caused by water ingress) but I have two gripes:

  • the batteries run flat and you never know when
  • time/day schedule trigger only so if it rained during the day you’re wasting water

For various reasons I parked this one and put it in the ‘too hard, do later’ basket. While there seemed to be lots of commercially available controllers out there that did everything I needed they were all relatively expensive and I had a few other projects on the backlog which were easier to tackle and give me more exposure into using RasPi’s and Arduino.

Roll on 2017 and it was time to finally give this a crack. After a bit of searching I came across the OpenSprinkler project which had a number of comparably cheap controllers that looked like would do the trick. There was also a plugin for my HA Controller (Homeseer) so again this was a good thing.

Given I only needed to control 3 zones, the OpenSprinkler Bee controller looked like the perfect option based on price and even included connectivity via wifi. I took the plunge and in less than a week it travelled around the world to my door step.

The device by default sets itself up as an Wifi AP so you connect to it and via Web Interface select your SSID of your Wifi network and enter in your password. It connected happily to my network and was up and running quickly.

I downloaded the Homeseer plugin only to find that it didn’t support the OSBee version only the main OpenSprinkler AC and DC versions. I’m not sure if there are plans to support it any time in the future but that therefore left it to me to sort out how I could interface with it.

I started out by creating a number of virtual devices as I needed to be able to track the status of the device as well as each of the zones and also put in a control which I could use to delay events based on rain/ground moisture levels or other triggers.

I had seen other plugins had used multiple rows of text in the status of a virtual device but I hadn’t worked it out. It seems it’s easier than I thought, all you have to do is pass html code to the status string and hey presto it shows up correctly like above. When I can be bothered I will probably decrease the font size here too.

Next I needed to built a script to populate the data and control the device. I split this into two sections:

  • Status Update – check the status of the device to make sure its connected and to show how much time is left on a programme before it turns it off
  • Device Control – send the signal to turn on the sprinkler and set a time for how long it will run for.
‘================================================================================ ‘ Script to Support OSBeeWifi OpenSprinkler ‘ Created by ShimmerNZ ‘ the following needs to be added to the ScriptingReferences entry in settings.ini in Homeseer/config directory ‘================================================================================ Sub StatusCheck(ByVal parm as Object) Imports System.Web.Script.Serialization Dim OSBeeStatus = “K4” Dim URLResponse as String  Try URLResponse = hs.GetURLEx(“10.1.1.187″,”/jc”,False,80) Dim json As New JavaScriptSerializer Dim dataObj As resultdata = json.Deserialize(Of resultdata)(URLResponse) hs.writelog( “Debug”,  URLResponse ) setDevStringByAddr(OSBeeStatus, “<b>Status:</b> Connected<br><b>Solenoid Type:</b> “&dataObj.sot & “<br> <b>Signal Strength:</b>”&dataObj.rssi & “db <br><b>Time Remaining:<b>”&dataObj.trem &”<br><b>Time Remaining:<b>”&dataObj.prem) setDevValueByAddr(OSBeeStatus, 100) Catch ex As Exception : setDevStringByAddr(OSBeeStatus, “<b>Status:</b> Not Connected<br><b>Error:</b> “& ex.message) : setDevValueByAddr(OSBeeStatus, 0) : hs.writelog(“OSBeeWifi”, “Exception: ” & ex.message) End Try GC.Collect() End Sub Sub Zone1(ByVal parm as Object) Dim ZoneValue = “K1” Dim Duration Duration = iGetDevValByAddr(ZoneValue) Try hs.GetURL(“10.1.1.187″,”/rp?dkey=opendoor&pid=77&zbits=1&dur=” & Duration,False,80) Catch ex As Exception : hs.writelog(“OSBeeWifi”, “Exception: ” & ex.message) End Try hs.WaitSecs(3) StatusCheck(“”) GC.Collect() End Sub Sub Zone2(ByVal parm as Object) Dim ZoneValue = “K2” Dim Duration Duration = iGetDevValByAddr(ZoneValue) Try hs.GetURL(“10.1.1.187″,”/rp?dkey=opendoor&pid=77&zbits=1&dur=” & Duration,False,80) Catch ex As Exception : hs.writelog(“OSBeeWifi”, “Exception: ” & ex.message) End Try hs.WaitSecs(3) StatusCheck(“”) GC.Collect() End Sub Sub Zone3(ByVal parm as Object) Dim ZoneValue = “K3” Dim Duration Duration = iGetDevValByAddr(ZoneValue) Try hs.GetURL(“10.1.1.187″,”/rp?dkey=opendoor&pid=77&zbits=1&dur=” & Duration,False,80) Catch ex As Exception : hs.writelog(“OSBeeWifi”, “Exception: ” & ex.message) End Try hs.WaitSecs(3) StatusCheck(“”) GC.Collect() End Sub Public Class resultdata Public Property sot As String Public Property prem As String Public Property trem As String Public Property zbits As String Public Property rssi As String End Class ‘================================================================================= ‘   Device String Update Function ‘================================================================================= private Sub setDevStringByAddr(ByVal DevAddrStr As String, ByVal strNewVal as String ) Dim intDevRef as Integer = hs.GetDeviceRef(DevAddrStr) if intDevRef <= 0 Then hs.writelog( “Error”, “setDevStringByAddr: device not found = ” & DevAddrstr ) else hs.SetDeviceString( intDevRef, strNewVal, TRUE ) end If End Sub ‘================================================================================= ‘   Device Value Update Function ‘================================================================================= private Sub setDevValueByAddr(ByVal DevAddrStr As String, ByVal strNewVal as String ) Dim intDevRef as Integer = hs.GetDeviceRef(DevAddrStr) if intDevRef <= 0 Then hs.writelog( “Error”, “setDevValueByAddr: device not found =” & DevAddrstr ) else hs.SetDeviceValueByRef( intDevRef, strNewVal, TRUE ) end If End Sub ‘================================================================================ ‘ iGetDevValByAddr: returns a device’s value as an integer ‘================================================================================ private Function iGetDevValByAddr(ByVal DevAddrStr As String ) as Integer Dim intDevRef as Integer = hs.GetDeviceRef(DevAddrStr) iGetDevValByAddr = -1 if intDevRef <= 0 Then hs.writelog( “Error”, “iGetDevValByAddr: device not found =” & DevAddrstr ) else iGetDevValByAddr = hs.DeviceValue( intDevRef ) end If End Function

As I was using a non latching solenoid the next thing I had to do was solder the jumper on the board. This wasn’t entirely intuitive that this needed to be done you have to read the blog carefully and the UI seems to imply it’s just a drop down menu and a reboot. That puzzled me for a few hours in the afternoon as otherwise when trigger it would pulse 24v and then it would drop to 0 as the cap grounded. Soldering the bridge then made it so that it would perm produce 24v when triggered.

I purchased the following 24v AC non latching valves from Aliexpress:

https://www.aliexpress.com/snapshot/0.html?orderId=81967063937034&productId=32499148544

I can confirm that these do work. In hindsight I probably should have gone for 3/4″ rather than 1″ but with a few adapters from the local hardware store I’m all sorted.

Leave a Reply

Your email address will not be published. Required fields are marked *