![]() |
|
LM5 Resident scripts can rarely freeze - Printable Version +- LogicMachine 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: LM5 Resident scripts can rarely freeze (/showthread.php?tid=2107) |
LM5 Resident scripts can rarely freeze - buuuudzik - 05.06.2019 Yesterday, my client give me the feedback that function OFF isn't now working. This function works in Resident 0s and its switch off near all lights in home and delays switch off of the lights on stairs. And script was halted, its status was "green" but this was a day so if it will be switched on at day it starts, do simple job and immediately disable itself so it was not working. I've found similar issue on other LM a few times but it was connected with HTTP or calculating statuses and small CPU power of devices. At this time this occured on LM5 with 20180523 firmware. I think it should be for sure solved, at least distinguish if some script is halted. This is a script (if during day it immediatelly should switch of): Code: -- Gdy noc, wtedy wyłącz całe oświetlenie wewn. oprócz korytarza i schodów, które wyłącz z opóźnieniem (od wywołania lub ostatniego ruchu w strefie dziennej).
-- Gdy dzień, wtedy całe oświetlenie wewn.
if not disableScript then
-- wstępna konfiguracja
disableScript = function()
grp.checkupdate("OFF_signalling", false)
script.disable(_SCRIPTNAME)
end
grp.checkupdate("OFF_signalling", true)
grp.write("OFF_Natychmiast", false)
grp.write("OFF_Później", not day) -- jeśli noc wtedy włącz oświetlenie orientacyjne m.in. schody
end
offset = grp.getvalue("OFF_Czas świecenia")
day = grp.getvalue("Dzień")
if day then
disableScript()
return
end
waitFromLastMotion = grp.getvalue("OFF_odliczaj od ruchu")
if waitFromLastMotion then
local motionInDayZone = grp.find("Ruch w strefie dziennej_status")
local lastMotion = motionInDayZone.updatetime
local motion = motionInDayZone.value
local elapsed = os.time() - lastMotion
if not motion and elapsed >= offset then
-- wyłącz oświetlenie korytarza
grp.write("OFF_Później", false)
disableScript()
elseif motion then
os.sleep(offset + 1)
else
-- odczekaj tyle co pozostało do 45
os.sleep(offset - elapsed + 1)
end
else
os.sleep(offset)
-- wyłącz oświetlenie korytarza
grp.write("OFF_Później", false)
disableScript()
endRE: LM5 Resident scripts can rarely freeze - admin - 05.06.2019 Try adding log calls before sleep (with sleep time to make sure that script is not just sleeping for too long) and disableScript. At least you will know where exactly your script stops working. RE: LM5 Resident scripts can rarely freeze - buuuudzik - 05.06.2019 Thanks for response? I can check this from OFF_signalling variable. But this I can check only in the future because now was updated. How os.sleep() works? Maybe there is some edge case and some mechanism cannot go back to script after os.sleep exceeded? Offset is 45s now and it is a number from 0-255. RE: LM5 Resident scripts can rarely freeze - admin - 05.06.2019 os.sleep calls C nanosleep internally. It has a built-in check that sleep time must be positive, so the issue is not there. |