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.

Delaytime not os.sleep()
#1
Hi,
I need a delay time function other than Os.sleep (). I have a problem when using the Os.sleep (30) function for the lamp, when counting time to 10s I turn off the lights and turn it back after nearly 20s the lights are off ....
I want to interrupt the os.sleep () function in the script when disabled

Please help me .. Sad  

Tks
Reply
#2
How you interrupt the counting? By the same group address?
Reply
#3
(16.05.2017, 15:22)buuuudzik Wrote: How you interrupt the counting? By the same group address?

Hi buuuudzik,
I have a problem using Os.sleep..It still stores count values and I have no way to change that.

Example:
When the script "Sleep" is triggered: the wall light will light for 5 minutes and then turn off.

As time goes by 2 minutes: I turn on the script "Living": turn on the wall light and downlight.

3 minutes after wall light off ...
------------ This is the problem that I encountered, this annoys me.

Plz help me, thank you very much
Reply
#4
For me the easiest solution is using Resident script. You can trigger resident script by some event.
Code:
grp.write('0/0/5', true)
os.sleep(10)
grp.write('0/0/5', false)

When you switch off the resident script it stops working without finishing script.
Reply
#5
Hi,

Event based scripts are running in parallel when executed multiple times. To avoid this you need to kill the previous instance of the script. Try using this  and fill it up with your original script and make sure to use a unique storage name for each script you use it in:

Code:
-- check if previous script needs to be killed
storage_name = 'PID_SCRIPT_1'
tpid = storage.get(storage_name)  
if tpid == nil then
   pid = os.getpid()
   storage.set(storage_name, pid)
else
   pid = os.getpid()  
   storage.set(storage_name, pid)  
   os.kill(tpid, signal.SIGKILL)
end

-- put here your script with os.sleep
os.sleep(10)
-- end of your scrript

-- clean up storage
storage.delete(storage_name)

BR,

Erwin
Reply
#6
This might help:
http://forum.logicmachine.net/showthread.php?tid=43
Reply
#7
Hi,
I try to try again in many ways.
Thank you very much Big Grin
Reply


Forum Jump: