Simple script for garden relying on rain

Moderator: leecollings

Post Reply
qbusr
Posts: 3
Joined: Friday 24 March 2017 19:03
Target OS: Linux
Domoticz version:
Contact:

Simple script for garden relying on rain

Post by qbusr »

Hi,
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

Could you help my with the lua code ? I am trying to get to know lua a little bit better
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Simple script for garden relying on rain

Post by zicht »

You could make use of wetherunderground , what is fully supported by domoticz.
The wether station can be added in the hardware tab and then the devices would appear in the table ( dont forget to add them :) )

Then you can read the values with lua from the wethersensors that are visible.
You just have to find a station with reliable rain measurement in you neighbourhood.

For wether underground you need to subscribe (Free) and get an api key on the site, i believe someone made a wiki about it.
https://www.domoticz.com/wiki/Virtual_weather_devices
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest