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.

test if resident script running
#6
Code:
mintimer = 1 -- minimum timer value in seconds
maxtimer = 60 -- maximum timer value in seconds

objects = {
 {
   output = '3/6/1',
   timer = '3/6/101',
 },
 {
   output = '3/6/2',
   timer = '3/6/102',
 },
 {
   output = '3/6/3',
   timer = '3/6/103',
 },
 {
   output = '3/6/4',
   timer = '3/6/104',
 },
 {
   output = '3/6/5',
   timer = '3/6/105',
 },
 {
   output = '3/6/6',
   timer = '3/6/106',
 },
 {
   output = '3/6/7',
   timer = '3/6/107',
 },
 {
   output = '3/6/8',
   timer = '3/6/108',
 }
}

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) -- conversione da secondi a minuti
 end
end

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

Let me show you. This above is a event scheduler which run when group 3/6/201 is triggered (true or false it does not matter)

If script status group is 32/1/3 do you mean insert this below in the same script above?

status = script.status('scriptname')
value = status
grp.write(32/1/3, value)

I did that. I use this instruction at the beginning of the script and at the end. Problem is that I never received false to group 32/1/3.

I hope you understand what you mean.

Thanks.
Reply


Messages In This Thread
RE: test if resident script running - by Domoticatorino - 26.04.2018, 11:52

Forum Jump: