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 whether you accept or reject these cookies being set.

Resident script stops working
#1
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

Best regards, Jørn.
Reply
#2
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
Reply
#3
That is unfortunately not the case. It shows active no matter what, and when trying to start it from another script nothing happens either.

Best regards, Jørn.
Reply
#4
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)
Reply
#5
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)`?

Best regards, Jørn.
Reply


Forum Jump: