This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Irrigation program
#1
Hi all,
any experience script about timer to manage an irrigation system with knx?

I have 10 irrigation valves which I control by knx. At starting time valves must open and closed step by step and when timer for one zone is expired start the followed zone.
The user must choose the working time for each valves and user can select which valves have to work. 

What do you suggest? 

Thanks.
Reply
#2
In order to simplify the question what is your idea to realize a countdown starting with a time insert by user?
Thanks.
Reply
#3
You can create a sequence with any number of outputs this way, just modify the parameters and object list to suit your needs:

Code:
mintimer = 5 -- minimum timer value in seconds
maxtimer = 60 -- maximum timer value in seconds

objects = {
  {
    output = '1/1/1',
    timer = '2/1/1',
  },
  {
    output = '1/1/2',
    timer = '2/1/2',
  },
  {
    output = '1/1/3',
    timer = '2/1/3',
  }
}

function dosleep(obj)
  local timer = grp.getvalue(obj)
  timer = tonumber(timer)

  if timer then
    if timer < mintimer then
      timer = mintimer
    elseif timer > maxtimer then
      timer = maxtimer
    end

    sleep(timer)
  end
end

for _, item in ipairs(objects) do
  grp.write(item.output, true)
  dosleep(item.timer)
  grp.write(item.output, false)
end
Reply
#4
(03.08.2016, 06:19)admin Wrote: You can create a sequence with any number of outputs this way, just modify the parameters and object list to suit your needs:

Code:
mintimer = 5 -- minimum timer value in seconds
maxtimer = 60 -- maximum timer value in seconds

objects = {
 {
   output = '1/1/1',
   timer = '2/1/1',
 },
 {
   output = '1/1/2',
   timer = '2/1/2',
 },
 {
   output = '1/1/3',
   timer = '2/1/3',
 }
}

function dosleep(obj)
 local timer = grp.getvalue(obj)
 timer = tonumber(timer)

 if timer then
   if timer < mintimer then
     timer = mintimer
   elseif timer > maxtimer then
     timer = maxtimer
   end

   sleep(timer)
 end
end

for _, item in ipairs(objects) do
 grp.write(item.output, true)
 dosleep(item.timer)
 grp.write(item.output, false)
end

Thank you but in case I would like to increase the time per zone? I mean that timer has to be from 1 minute to 30 minutes. How can I do that?

Thanks.
Reply
#5
If you're fine with having timer resolution in minutes not seconds, this should work:

Code:
mintimer = 1 -- minimum timer value in minutes
maxtimer = 30 -- maximum timer value in minutes

objects = {
  {
    output = '1/1/1',
    timer = '2/1/1',
  },
  {
    output = '1/1/2',
    timer = '2/1/2',
  },
  {
    output = '1/1/3',
    timer = '2/1/3',
  }
}

function dosleep(obj)
  local timer = grp.getvalue(obj)
  timer = tonumber(timer)

  if timer then
    if timer < mintimer then
      timer = mintimer
    elseif timer > maxtimer then
      timer = maxtimer
    end

    sleep(timer * 60) -- minutes -> seconds
  end
end

for _, item in ipairs(objects) do
  grp.write(item.output, true)
  dosleep(item.timer)
  grp.write(item.output, false)
end
Reply
#6
Hi admin,
I finally test it and it is work fine. What I would like to do is add, for every step an enable.
I mean that it enable object is =1 then system active the output for the time declared otherwise syste shift to the next step.
What lua instruction I could use?
Thanks.
Reply
#7
Code:
mintimer = 1 -- minimum timer value in minutes
maxtimer = 30 -- maximum timer value in minutes

objects = {
  {
    output = '1/1/1',
    timer = '2/1/1',
    enable = '3/1/1',
  },
  {
    output = '1/1/2',
    timer = '2/1/2',
    enable = '3/1/3',
  },
  {
    output = '1/1/3',
    timer = '2/1/3',
    enable = '3/1/3',
  }
}

function dosleep(obj)
  local timer = grp.getvalue(obj)
  timer = tonumber(timer)

  if timer then
    if timer < mintimer then
      timer = mintimer
    elseif timer > maxtimer then
      timer = maxtimer
    end

    sleep(timer * 60) -- minutes -> seconds
  end
end

for _, item in ipairs(objects) do
  if grp.getvalue(item.enable) then
    grp.write(item.output, true)
    dosleep(item.timer)
    grp.write(item.output, false)
  end
end
Reply
#8
Hi all

in case of needing to interrupt sequence (raining at that moment), how should we modify the code?
Reply
#9
Are you using a scheduled script for this?
Reply
#10
(12.03.2019, 07:35)admin Wrote: Are you using a scheduled script for this?

yes. but I need the sequence stops when it's raining to save water
Reply
#11
There's no built-in way to stop a scheduled script, but you can use this script (change script name to your scheduled script name):
Code:
name = 'my script name'
item = script.get(name)
script.disable(name)
os.execute('pkill -f "scripting-scheduled.lua ' .. item.id .. '"')

You should also add sending 0 to all outputs.
Reply
#12
(12.03.2019, 08:30)Thanks!!. Works welladmin Wrote: There's no built-in way to stop a scheduled script, but you can use this script (change script name to your scheduled script name):
Code:
name = 'my script name'
item = script.get(name)
script.disable(name)
os.execute('pkill -f "scripting-scheduled.lua ' .. item.id .. '"')

You should also add sending 0 to all outputs.
Reply
#13
Thanks !!!
Reply
#14
hi,

Is it possible to enable a delay on each of these timers?
I mean on the output:-)

Daniel
Reply
#15
(12.03.2019, 08:30)admin Wrote: There's no built-in way to stop a scheduled script, but you can use this script (change script name to your scheduled script name):
Code:
name = 'my script name'
item = script.get(name)
script.disable(name)
os.execute('pkill -f "scripting-scheduled.lua ' .. item.id .. '"')

You should also add sending 0 to all outputs.
Hi, I've found this script to stop an event scripting, I've tested but if the scripting is running it doesn't stop. Or better the led of status passes red and doesn't start in next event occured. Is It possible stop the event?
Best regards Cristian
Reply
#16
https://forum.logicmachine.net/showthrea...1#pid19051
------------------------------
Ctrl+F5
Reply
#17
(30.06.2021, 14:57)Daniel. Wrote: https://forum.logicmachine.net/showthrea...1#pid19051

Thanks
Reply
#18
Hello!
How do I start this script at a certain time, selecting the days of the week? The selection will be made by the user.
Thank you!
Reply
#19
(11.05.2022, 11:42)costelservice@gmail.com Wrote: Hello!
How do I start this script at a certain time, selecting the days of the week? The selection will be made by the user.
Thank you!

Hi , you can creat a new object and on the new object creat a scheduler then remote irrigation script.
Code:
[code]value = event.getvalue()
if value == true then
  os.sleep(3)
  grp.write("8/0/8",false)
end
function dosleep(obj)
  local timer = grp.getvalue(obj)
  timer = tonumber(timer)
  if timer then
    if timer < mintimer then
      timer = mintimer
    elseif timer > maxtimer then
      timer = maxtimer
       
    end
    os.sleep(timer *60 ) -- minutes -> seconds
  end
end


mintimer = 0.1 -- minimum timer value in minutes
maxtimer = 30 -- maximum timer value in minutes

objects = {
      {
    output = '8/2/0',
    timer = '33/5/8',   
    enable = '33/5/9',



  }
}


for _, item in ipairs(objects) do
  if grp.getvalue(item.enable) then
    grp.write(item.output, true)
    dosleep(item.timer)
    grp.write(item.output, false)
    grp.write('8/1/0',false)

   

 
  end
end
Reply
#20
Hello,

I tried to use this script by event but there's no way to stop the script once started. 

Code:
name = 'my script name'
item = script.get(name)
script.disable(name)
os.execute('pkill -f "scripting-scheduled.lua ' .. item.id .. '"')

I used the script you suggested before but didn't work for me. I'm using a group address to trigger the event script with value 1 and would like to use the same group address with value 0 to stop the script. Do you know what could be happening? Thank you.
Reply


Forum Jump: