Page 1 of 1

new irrigation program

Posted: Sunday 14 April 2019 19:36
by pvklink
Hi, i made a extention for my irrigation program.

description:
Garden has four zones.Each zone has a duration (10-60 minutes)
I can manually put each zone on or off (see second script in this post) each zone has its own duration value for how long to irrigate.

This new script starts automatic by a timer, the first zone is then activated.
The next zone starts 1 minute (variable) after the duration of the previous zone. This is because i dont have enough pressure to activate them all together. The script is working well. To get it 100% still have a some problems:

1) writing to the log:

dz.log("Script: " .. info.scriptName .. " Device: Tuinirrigatie_border_rechts, wordt aangezet, om:" .. tostring(now + aftertimer) .. " voor " .. devtimer2 .. " minuten....", dz.LOG_INFO)
gives an error, i want to log current_time +aftertimer as a timestamp (aftertimer is normally about 11 minutes, 10 minutes duration and 1 minute pause between the zones)

2) in the second script i put switches on off for x minutes. In this automatic script i want to activate these manually defined actions after some time and all after each other. I think i have programmed to much actions double like the duration of the irrigation, this is defined in autoamtic timer script and in the manual script...

<automatic timer script>

Code: Select all

local Tuinirrigatie = 'at 19:23 on mon,tue,wed,thu,fri,sat,sun'

return {
	on =    {timer = {Tuinirrigatie}},
        
    logging =   { level   = domoticz.LOG_DEBUG ,                  
                  marker  = "Timers irrigatie"},
              
    execute = function(dz,item,info)
    local switch        = dz.devices('Irrigatietimers')
    local switch2       = dz.devices('hetregent')
    local now           = os.time(os.date('*t'))      
    local devpauze      = 1
    local devcor        = 9 -- this is for testing. put this to 9 and set all the irrigation duration switches to 10. every irrigation periode is then 10-9

    if switch.state == 'Off' then                                                       
        dz.log("Script: " .. info.scriptName .. " is niet aangezet, switch: " .. switch.name .. " staat uit", dz.LOG_INFO)
    else
        if switch2.state == 'Off' then                                                       
    
                devtimer1 = tonumber(dz.devices('Tuinirrigatie_border_links_waarde').level - devcor)
                dz.devices('Tuinirrigatie_border_links').switchOn().checkFirst().forMin(devtimer1)  
                dz.log("Script: " .. info.scriptName .. " Device: Tuinirrigatie_border_links, aangezet, om:" .. tostring(now) .. " voor " .. devtimer1 .. " minuten....", dz.LOG_INFO)    
    
                devtimer2 = tonumber(dz.devices('Tuinirrigatie_border_rechts_waarde').level - devcor)
                aftertimer = devtimer1 + devpauze

               --dz.device(Tuinirrigatie_border_rechts).cancelQueuedCommands()

                dz.devices('Tuinirrigatie_border_rechts').switchOn().checkFirst().afterMin(aftertimer).forMin(devtimer2)  
                --dz.log("Script: " .. info.scriptName .. " Device: Tuinirrigatie_border_rechts, wordt aangezet, om:" .. tostring(now + aftertimer) .. " voor " .. devtimer2 .. " minuten....", dz.LOG_INFO)    

                devtimer3 = tonumber(dz.devices('Tuinirrigatie_gazon_waarde').level - devcor)
                aftertimer = aftertimer+devtimer2 + devpauze

                --dz.device('Tuinirrigatie_gazon').cancelQueuedCommands()

                dz.devices('Tuinirrigatie_gazon').switchOn().checkFirst().afterMin(aftertimer).forMin(devtimer3)  
                --dz.log("Script: " .. info.scriptName .. " Device: Tuinirrigatie_gazon, wordt aangezet, om:" .. tostring(now + aftertimer) .. " voor " .. devtimer3 .. " minuten....", dz.LOG_INFO)    

                devtimer4 = tonumber(dz.devices('Tuinirrigatie_planten_waarde').level - devcor)
                aftertimer = aftertimer+devtimer3 + devpauze

                --dz.device('Tuinirrigatie_planten').cancelQueuedCommands()

                dz.devices('Tuinirrigatie_planten').switchOn().checkFirst().afterMin(aftertimer).forMin(devtimer4)  
                --dz.log("Script: " .. info.scriptName .. " Device: Tuinirrigatie_planten, wordt aangezet, om:" .. tostring(now + aftertimer) .. " voor " .. devtimer4 .. " minuten....", dz.LOG_INFO)    

        else
    
            dz.log("Script: " .. info.scriptName .. " is niet aangezet, het is aan t regenen... ", dz.LOG_INFO)
        end
    end

end
}

<script for manual operation>
I use this code to start the four different zones/devices, this script is not for an automatic irrigation the garden, but for manualy active the four timers on or off for a period of time as (switches with levels)...

Code: Select all

return {
    on = {devices = {'Tuinirrigatie_gazon','Tuinirrigatie_border_links','Tuinirrigatie_planten','Tuinirrigatie_border_rechts'}},

    logging = { 
                    level   = domoticz.LOG_INFO,
                    marker  = "Tuinirrigatie",
              },

    execute = function(dz, device, info)
    devtimer = tonumber(dz.devices(device.name .. '_waarde').level)  -- timer ophalen. timer heeft altijd de naam van het device met _waarde erachter

    if device.state == 'Off' then
        device.cancelQueuedCommands()
        dz.log("Script: " .. info.scriptName .. " Device " .. device.name .. " Uitgezet....", dz.LOG_INFO)    
    else 
        device.switchOff().afterMin(devtimer).silent()
        dz.log("Script: " .. info.scriptName .. " Device " .. device.name .. " aangezet, om:" .. dz.time.rawTime .. " voor " .. devtimer .. " minuten....", dz.LOG_INFO)    
    end

end
}

Re: new irrigation program

Posted: Sunday 14 April 2019 20:45
by pvklink
Problems solved

1) defined another logmessage so that i dont have to do arithmic with time values
dz.log("Script: " .. info.scriptName .. ", device: Tuinirrigatie_border_rechts, wordt aangezet " .. tostring(aftertimer) .. " min na " .. dz.time.rawTime .. " en voor " .. devtimer2 .. " minuten....", dz.LOG_INFO)

2) i removed .formin in the automatic script, manual script is taking care for the duration of the irrigation. the automatic script only fires the swiches on after a period...
dz.devices('Tuinirrigatie_border_links').switchOn().checkFirst() for the first zone and
dz.devices('Tuinirrigatie_border_rechts').switchOn().checkFirst().afterMin(aftertimer) for the next zone

it all works great now...

Re: new irrigation program

Posted: Sunday 14 April 2019 23:09
by Dutchsea
Hi, what kind of hardware do you use for your irrigation? Myself i use a Gardena system (MultiControl duo) but it cant be remotely operated. It has its own pcboard and 2 watervalves that are operated by magnets.

Re: new irrigation program

Posted: Monday 15 April 2019 11:56
by pvklink
hi,
i made it myself with 4 sunboiler relais and kaku switch

Re: new irrigation program

Posted: Monday 15 April 2019 12:48
by Dutchsea
Could you post a link of such a relay, thank you.

Re: new irrigation program

Posted: Monday 15 April 2019 13:24
by pvklink

Re: new irrigation program

Posted: Monday 15 April 2019 17:25
by Dutchsea
That is a nice one. I see it is also available in a 12V version. I like to create a battery operated system so i do not need to install a power line to my outside tap. Just need to find a low energy, battery powered, switch that works with RFX433, Zwave or Zigbee.

(initially i was looking at a washing machine valve, yours is better)

Re: new irrigation program

Posted: Monday 15 April 2019 17:27
by pvklink
Mine is working Perfect, manually and automatic and by speech !