Logic Machine Forum
test if resident script running - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: test if resident script running (/showthread.php?tid=1324)



test if resident script running - rocfusion - 29.03.2018

Hi,

It is possible to test whether a resident script is running?

Thanks,

Roger


RE: test if resident script running - buuuudzik - 29.03.2018

(29.03.2018, 19:42)rocfusion Wrote: Hi,

It is possible to test whether a resident script is running?

Thanks,

Roger

From the manual on the left side of Script Editor:
Code:
script.status('scriptname')



RE: test if resident script running - rocfusion - 30.03.2018

Perfect, thank you..


RE: test if resident script running - Domoticatorino - 26.04.2018

Hi buuuudzik,
I would like to link the status of a script to an object.

So, I use status script.status('scriptname') but in order to do that I have to create another script?

status = script.status ('Sequenza Irrigazione 1')
Value = status
grp.write('32/1/3', value)

But who trigger this script? So does it become a dangerous loop?

Thanks.


RE: test if resident script running - buuuudzik - 26.04.2018

If you want to have such mapping better is to managing script by this object and not in other place.

So e.g. you have your script "Irrigating" and you use script.enable and script.disable only in event script for object e.g. 2/2/2 'Irrigating on/off'

You can also add something in Init script.


RE: test if resident script running - Domoticatorino - 26.04.2018

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.


RE: test if resident script running - buuuudzik - 26.04.2018

In this case actually you have object and now I see that you have some os.sleep. So you can do it like below:

Code:
scriptStatusGA = '32/1/3'

grp.checkupdate(scriptStatusGA, true)

-- YOUR SCRIPT

grp.update(scriptStatusGA, false)



RE: test if resident script running - Domoticatorino - 27.04.2018

Great!! Thank you very much