I have three dummy switches which control my sprinkler valves (I have 3 loops in my garden) - i control my electrovalves via Wifi IoT Relay Board Based on ESP8266 and MQTT. Right now it is simple and working - i have group of those three switches (with on/off delays). But i would like to prevent EV from work if it has rained earlier (i would like to check it eg for 10hr). Right now i don't have any wheather station and rely on darksky wheather forecast. What I am thinking of is time LUa script, which would do something like that (pseudocode, I am not programmer (yet

Code: Select all
--set variable in minutes, when my group should switch on, here 60 min before sunset
groupHeadStart = 60
--set variable when to start monitoring rain, here for 10hr before sunset = 600 min
checkRainStart = 600
--set time when groups sets on
GroupStart = timeofday['SunsetInMinutes'] - groupHeadStart
--start checking if it has rained, my rain sensor from darkssky is called t1 and has idx = 6
timenow = os.date("*t")
minutesNow = timenow.min + timenow.hour * 60
if minutesNow >= GroupStart - chceckRainStart / if it is less than 10 hr to start the sprinkler group check if it has rained and set variable
if t1 > 0 //i have to values from my sensor, but i don't know what they are - i presume one is current raindrop
set global variable itHasRained -> 1
else
pass
--turn on the group
if minutesNow == GroupStart
if vglobal variable itHasRained == 0
set group on
else
pass
--reset variable during the night
if minutesNow ==0
set global variable itHasRained -> 0