new irrigation program
Posted: Sunday 14 April 2019 19:36
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>
<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)...
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
}