piBeacon: 11- sprinkler control
Posted:
Wed May 23, 2018 8:35 am
by kw123
This thread will discuss using pibeacon as a sprinkler valve controller.
The description will grow over time
The functionality will cover:
1. drive sprinkler relays to switch valves on/off (4...16 valves), using regular indigo actions
2. add some sensor, moisture, temp, humidity .. if you like
3. how to attach a display and show the sprinkler settings and stats and actions
4. add (touch) switches for sprinkler functions, eg start, stop, next zone.
costs:
1. RPI $35
2. box $10
3. display $ 30
4. 24v AC to 5V BUK $5
5. Some cables, connectors for valves , ethernet plug .. $5-10
you likely can get a cheaper one, but doing this .. you did it yourself -- . and it can serve as a regular pibeacon BLE RPI detecting BLE devices (iPhones, and ibeacons)
Karl
Re: piBeacon: 11- sprinkler control
Posted:
Sun Jun 03, 2018 10:11 am
by kw123
display code for a script to show the above screen on the attached display:
- Code: Select all
import datetime
dev = indigo.devices[1757238557]
props = dev.pluginProps
zNames = dev.zoneNames
nZones = dev.zoneCount
durations = dev.zoneScheduledDurations
zoneMaxDur = dev.zoneMaxDurations
zoneStarted = dev.states["activeZoneStarted"]
timeLeft = str(dev.states["activeZoneMinutesLeft"])
dur = str(dev.states["activeZoneMinutesDuration"])
timeLeftALL = str(dev.states["allZonesMinutesLeft"])
durALL = str(dev.states["allZonesMinutesDuration"])
aText = "Zones off"
onTime = "1"
try:
activeZone = int(dev.states["activeZone"])
except:
activeZone = 0
if activeZone > 0 and len(zoneStarted) > 10:
if len(durations) >1:
aText = "Zone # "+str(activeZone)+"; start:"+ zoneStarted[10:-3]+"; dur:"+dur+"; left:"+ timeLeft+"; ALL-dur:"+durALL+"; left:"+ timeLeftALL +" [min]"
else:
aText = "Zone # "+str(activeZone)+"; manual start:"+ zoneStarted[10:-3]+"; dur:"+dur+"; left:"+ timeLeft+" [min]"
else:
onTime = "3"
aText = "sprinklers OFF"
tDay = dev.states["minutesRunToday"].split(",")
yDay = dev.states["minutesRunYesterday"].split(",")
tWeek = dev.states["minutesRunThisWeek"].split(",")
lWeek = dev.states["minutesRunLastWeek"].split(",")
tMonth = dev.states["minutesRunThisMonth"].split(",")
lMonth = dev.states["minutesRunLastMonth"].split(",")
line = ["" for ii in range(10)]
for ii in range(len(zNames)):
line[ii] = "%2d "%(ii+1)
line[ii] += (zNames[ii][0:11]).ljust(11)
line[ii] += tDay[ii].rjust(3)
line[ii] += yDay[ii].rjust(5)
line[ii] += tWeek[ii].rjust(5)
line[ii] += lWeek[ii].rjust(5)
line[ii] += tMonth[ii].rjust(6)
line[ii] += lMonth[ii].rjust(6)
plug = indigo.server.getPlugin("com.karlwachs.piBeacon")
plug.executeAction("Display" , props ={
"outputDev":"601124473"
,"device":"OUTPUT-Display"
,"restoreAfterBoot":"False"
,"intensity":""
,"repeat":"9999999"
,"resetInitial":"(0,0,0)"
,"scrollxy":""
,"showDateTime":"0"
,"startAtDateTime":"0"
,"scrollPages":""
,"scrollDelay":""
,"scrollDelayBetweenPages":""
,"command":'['+
'{"type":"rectangle", "position":[0,0,800,600], "fill":[50, 50,50], "display":"wait"}'+
',{"type":"text", "position":[0,0], "width":20, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":" Zone Min.: Day YestD Week LWeek Month LMonth" }'+
',{"type":"text", "position":[5,25], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[0]+'" }'+
',{"type":"text", "position":[5,50], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[1]+'" }'+
',{"type":"text", "position":[5,75], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[2]+'" }'+
',{"type":"text", "position":[5,100], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[3]+'" }'+
',{"type":"text", "position":[5,125], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[4]+'" }'+
',{"type":"text", "position":[5,150], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[5]+'" }'+
',{"type":"text", "position":[5,175], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[6]+'" }'+
',{"type":"text", "position":[5,200], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[7]+'" }'+
',{"type":"text", "position":[5,225], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[8]+'" }'+
',{"type":"text", "position":[5,250], "width":22, "fill":[0, 255, 0], "display":"wait", "font":"Andale Mono.ttf", "text":"'+ line[9]+'" }'+
',{"type":"text", "position":[5,275], "width":28, "fill":[255, 0, 0], "display":"wait", "font":"Arial.ttf", "text":"'+aText+'", "offONTime":[0, '+onTime+', 1] }'+
',{"type":"text", "position":[5,315], "width":30, "fill":[255,255, 255], "display":"wait", "font":"Andale Mono.ttf", "text":"Outside Temp" }'+
',{"type":"textWformat", "position":[203,315],"width":30, "fill":[255,255, 255], "display":"wait", "font":"Andale Mono.ttf", "text":"%%d:340764825:Temperature%%FORMAT%5d [F]" }'+
',{"type":"text", "position":[5,350], "width":30, "fill":[255,255, 255], "display":"wait", "font":"Andale Mono.ttf", "text":" Hum. %%d:340764825:Humidity%% %" }'+
',{"type":"text", "position":[5,390], "width":30, "fill":[255,255, 255], "display":"wait", "font":"Andale Mono.ttf", "text":" Rain Today" }'+
',{"type":"textWformat", "position":[203,390],"width":30, "fill":[255,255, 255], "display":"wait", "font":"Andale Mono.ttf", "text":"%%d:57636140:currentDayTotal%%FORMAT%5.1f [in]" }'+
',{"type":"dateString", "position":[10,425], "width":50, "fill":[255, 255, 255], "display":"wait", "font":"Arial.ttf", "text":"%a, %b %d, %Y" }'+
',{"type":"digitalClock","position":[550,425],"width":50, "fill":[250, 255, 50], "display":"immediate","font":"Arial.ttf", "box":{"on": "box", "width": "250", "height": "60", "fill": [0, 0, 0]} }]'
})