Logic Machine Forum
Resident script stops working - 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: Resident script stops working (/showthread.php?tid=2289)



Resident script stops working - Jørn - 16.10.2019

What would stop a resident script from running`?
I've got several resident scripts that sometimes just stop running, it shows active in script listing, but according to Processes app it does not run.
Works like normal after turning it off and on again.
Nothing appears in error logs.

This is the script most commonly to stop working, i've checked many times that all all GA's have set values like they should etc.
Code:
Output = 'scene mainbedroom'
outputvalue = 13
countdown = 'cd time mainbedroom'
mode = grp.getvalue('lightmode mainbedroom')
updatetime = storage.get('movement_mb', 0)
delta = os.time() - updatetime
pir_active = grp.getvalue('pir mainbedroom')

if pir_active == false then
  script.disable(_SCRIPTNAME)
end

cdactive = false
if mode == 1 then
  runtime = grp.getvalue('rt_m_mainbedroom')
elseif mode == 2 then
  runtime = grp.getvalue('rt_d_mainbedroom')
elseif mode == 3 then
  runtime = grp.getvalue('rt_e_mainbedroom')
elseif mode == 4 then
  runtime = grp.getvalue('rt_l_mainbedroom')
elseif mode == 5 then
  runtime = 5
end

if outputvalue == grp.getvalue(output) then
  if cdactive == true then
    grp.update(countdown, 0)
  end
  script.disable(_SCRIPTNAME)
end

if cdactive == true then
  timeleft = (runtime * 60) - delta
  grp.update(countdown, timeleft)
end

-- turn off when timer expires
if delta >= (runtime * 60) then
  grp.write(output, outputvalue)
  if cdactive == true then
    grp.update(countdown, 0)
  end
  script.disable(_SCRIPTNAME)
end

if pir_active == false then
  script.disable(_SCRIPTNAME)
end



RE: Resident script stops working - Erwin van der Zwart - 16.10.2019

Hi,

You have several script.disable(_SCRIPTNAME) in your script, this means it will stop current script, the indication that script is active can be wrong when you don't press refresh as its not updated when disable a script from script. Refresh your browser when it occurs again, i think it will show "disabled"

BR,

Erwin


RE: Resident script stops working - Jørn - 16.10.2019

That is unfortunately not the case. It shows active no matter what, and when trying to start it from another script nothing happens either.


RE: Resident script stops working - admin - 16.10.2019

How often does this happen and which HW version are you using? Can you send backup via PM so we can run the same setup locally and check if the same thing happens?
You also try running your script like this:
Code:
while true do
  -- YOUR SCRIPT HERE
  sleep(10)
end
Adjust sleep time as needed and add break after each script.disable(_SCRIPTNAME)


RE: Resident script stops working - Jørn - 16.10.2019

It's a LM5p-DW1 running 20180828 firmware. Once or twice a week. I'll do those changes to the scripts and try it out ;o)

EDIT; Should i set resident sleep time to 0 when using sleep(10)`?