24.10.2023, 08:38
Which script are you trying to disable and stop? The script above is for Scheduled script only.
------------------------------
Ctrl+F5
Ctrl+F5
Irrigation program
|
24.10.2023, 08:38
Which script are you trying to disable and stop? The script above is for Scheduled script only.
------------------------------
Ctrl+F5
24.10.2023, 08:47
(24.10.2023, 08:38)Daniel Wrote: Which script are you trying to disable and stop? The script above is for Scheduled script only. Code: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 value = event.getvalue()
if value == true then
--os.sleep(3)
--grp.write("5/0/1",false)
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 = 60 -- maximum timer value in minutes
objects = {
{
output = '5/1/1',
timer = '5/3/1',
enable = '5/4/1',
},
{
output = '5/1/2',
timer = '5/3/2',
enable = '5/4/2',
},
{
output = '5/1/3',
timer = '5/3/3',
enable = '5/4/3',
},
{
output = '5/1/4',
timer = '5/3/4',
enable = '5/4/4',
},
{
output = '5/1/5',
timer = '5/3/5',
enable = '5/4/5',
},
{
output = '5/1/6',
timer = '5/3/6',
enable = '5/4/6',
},
{
output = '5/1/7',
timer = '5/3/7',
enable = '5/4/7',
},
{
output = '5/1/8',
timer = '5/3/8',
enable = '5/4/8',
},
{
output = '5/1/9',
timer = '5/3/9',
enable = '5/4/9',
},
{
output = '5/1/10',
timer = '5/3/10',
enable = '5/4/10',
}
}
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
grp.write("5/0/1",false)
endThis is the script i'm using as event-based script.
24.10.2023, 08:50
Set event script "Execution mode" to "Last instance only".
24.10.2023, 09:17
24.10.2023, 09:18
In event script settings. You need 2023 or newer firmware for this.
24.10.2023, 09:39
Ok so I'll have an event-based script for the irrigation program configured as last instance only execution mode.
Code: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 value = event.getvalue()
if value == true then
--os.sleep(3)
--grp.write("5/0/1",false)
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 = 60 -- maximum timer value in minutes
objects = {
{
output = '5/1/1',
timer = '5/3/1',
enable = '5/4/1',
},
{
output = '5/1/2',
timer = '5/3/2',
enable = '5/4/2',
},
{
output = '5/1/3',
timer = '5/3/3',
enable = '5/4/3',
},
{
output = '5/1/4',
timer = '5/3/4',
enable = '5/4/4',
},
{
output = '5/1/5',
timer = '5/3/5',
enable = '5/4/5',
},
{
output = '5/1/6',
timer = '5/3/6',
enable = '5/4/6',
},
{
output = '5/1/7',
timer = '5/3/7',
enable = '5/4/7',
},
{
output = '5/1/8',
timer = '5/3/8',
enable = '5/4/8',
},
{
output = '5/1/9',
timer = '5/3/9',
enable = '5/4/9',
},
{
output = '5/1/10',
timer = '5/3/10',
enable = '5/4/10',
}
}
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
grp.write("5/0/1",false)
endAnd then I also need an event-based script in normal execution mode like the shown below in order to stop the irrigation program. Is that correct? Thank you! Code: 123456 value = event.getvalue()
if value == false then
name = 'my script name'
item = script.get(name)
script.disable(name)
os.execute('pkill -f "scripting-scheduled.lua ' .. item.id .. '"')
24.10.2023, 09:45
You don't need an extra script for this. In "Last instance only" mode all previous script instances are stopped once new value arrives.
Your script should be modified to turn off all outputs when false is received. This is needed because when the script is running it's mostly sleeping with one output turned on. Code: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 value = event.getvalue()
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 = 60 -- maximum timer value in minutes
objects = {
{
output = '5/1/1',
timer = '5/3/1',
enable = '5/4/1',
},
{
output = '5/1/2',
timer = '5/3/2',
enable = '5/4/2',
},
{
output = '5/1/3',
timer = '5/3/3',
enable = '5/4/3',
},
{
output = '5/1/4',
timer = '5/3/4',
enable = '5/4/4',
},
{
output = '5/1/5',
timer = '5/3/5',
enable = '5/4/5',
},
{
output = '5/1/6',
timer = '5/3/6',
enable = '5/4/6',
},
{
output = '5/1/7',
timer = '5/3/7',
enable = '5/4/7',
},
{
output = '5/1/8',
timer = '5/3/8',
enable = '5/4/8',
},
{
output = '5/1/9',
timer = '5/3/9',
enable = '5/4/9',
},
{
output = '5/1/10',
timer = '5/3/10',
enable = '5/4/10',
}
}
for _, item in ipairs(objects) do
if value == true then
if grp.getvalue(item.enable) then
grp.write(item.output, true)
dosleep(item.timer)
grp.write(item.output, false)
end
else
grp.checkwrite(item.output, false)
end
end |
« Next Oldest | Next Newest »
|