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.

Understanding timed scripting
#1
I´m having some problems understanding why my tried timers don´t work as I want them to.

I have these two scripts, in two scheduled scripts:

Code:
-- Trigger
trig = '3/5/7'
-- set 100%
max = '3/5/6'
-- store scene
lagre = '1/4/5'
-- get scene
hent = '1/4/6'
--status
status = '3/4/38'
-- locking PIRs
PIRlock = '1/3/19'
-- find required object
obj1 = grp.find(trig)
-- object exists and current state is "on"
if obj1 and obj1.data then
grp.write(lagre, 0, dt.uint8)
grp.write(max, 100, dt.scale)
grp.write(status, 1, dt.bool)
grp.write(PIRlock, 1, dt.bool)
-- delta is in seconds
delta = os.time() - obj1.updatetime
-- switch off when timer expires
if delta >= 60 * 60 then
grp.write(hent, 128, dt.uint8)
grp.write(status, 0, dt.bool)
grp.write(PIRlock, 0, dt.bool)
end
end

The first one is to trigger 100% lighting for one hour, for cleaning purposes. It also locks the PIRs, saves the lighting state before setting 100% and sets a status object so we know it is in play.

However, when I activate the script, everything just goes to 100% immediately. If i try to put it in a normal event script, nothing happens when I push the button....
Code:
-- group address or name
addr1 = '3/5/8'
addr2 = '1/1/50'
addr3 = '3/5/9'
-- find required object
obj = grp.find(addr1)
-- object exists and current state is "on"
if obj and obj.data then
grp.write(addr2, 28, dt.scale)
grp.write(addr3, true)
-- delta is in seconds
delta = os.time() - obj.updatetime
-- switch off when timer expires
if delta >= 6 * 60 then
grp.write(addr2, 22, dt.scale)
end
if delta >= 12 * 60 then
grp.write(addr2, 16, dt.scale)
end
if delta >= 18 * 60 then
grp.write(addr2, 10, dt.scale)
end
if delta >= 24 * 60 then
grp.write(addr2, 4, dt.scale)
end
if delta >= 30 * 60 then
grp.write(addr2, 0, dt.scale)
grp.write(addr3, false)
end
end

This last one is for slowly dimming down the lights in a kids room. However, when I activate this script, whenever the lights is turned on normal, it will always dim down and go dark after a while....

What am I missing here..?
Reply


Messages In This Thread
Understanding timed scripting - by FatMax - 19.03.2016, 10:13
RE: Understanding timed scripting - by admin - 21.03.2016, 07:17

Forum Jump: