Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
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.
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
In order to simplify the question what is your idea to realize a countdown starting with a time insert by user?
Thanks.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
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
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
(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.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
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
Posts: 400
Threads: 88
Joined: Jul 2016
Reputation:
3
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.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
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
Posts: 6
Threads: 2
Joined: Apr 2018
Reputation:
1
Hi all
in case of needing to interrupt sequence (raining at that moment), how should we modify the code?
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Are you using a scheduled script for this?
Posts: 6
Threads: 2
Joined: Apr 2018
Reputation:
1
(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
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
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.
Posts: 6
Threads: 2
Joined: Apr 2018
Reputation:
1
(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.
Posts: 6
Threads: 2
Joined: Apr 2018
Reputation:
1
Posts: 9
Threads: 2
Joined: Mar 2019
Reputation:
0
hi,
Is it possible to enable a delay on each of these timers?
I mean on the output:-)
Daniel
Posts: 305
Threads: 59
Joined: Dec 2019
Reputation:
12
(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
Posts: 4643
Threads: 24
Joined: Aug 2017
Reputation:
207
------------------------------
Ctrl+F5
Posts: 305
Threads: 59
Joined: Dec 2019
Reputation:
12
Posts: 3
Threads: 1
Joined: Jan 2019
Reputation:
0
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!
Posts: 151
Threads: 27
Joined: May 2017
Reputation:
2
12.05.2022, 11:47
(This post was last modified: 12.05.2022, 11:53 by balatis.)
(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
Posts: 16
Threads: 3
Joined: May 2016
Reputation:
0
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.
|