(03.08.2017, 08:05)Kuronen Wrote: Being new to LUA I´m finding it difficult to get everything right. Could some one help me with below.?? PleaseHi!
I have tried to create a simple Staircase timer for lighting control with the following functions:
1bit KNX command = true activates (From presence detector)
(1.) Sends a KNX Byte value "90%"
(2.) After not receiving (1bit from presence detector) in 30 min send KNX byte value 20%
(3.) After not receiving (1bit from presence detector) in 60 min send KNX byte value 0%
(( If triggered by 1bit from presence detector it should re-trigger the staircase timer.))
I need to run multiple staircase timers for different areas with the same LM unit.!
here is example. but its not good to use so big os.sleep timer in event based script
just add event based script for your presense sensor group address
Code:
scale_adress= '1/1/4'
value = event.getvalue()
storage_name = 'staircase '..event.dst
if value then
-- writing 100% to scale object
grp.write(scale_adress, 100)
-- getting object info
obj = grp.find(event.dst)
--getting update time of presense sensor in seconds
upd_time = obj.updatetime
--setting this update time to storage
storage.set(storage_name, upd_time)
--(watinng for 40 minutes)
os.sleep (40*60)
-- checking if the sensor was updated
n_obj = grp.find(event.dst)
n_upd_time = n_obj.updatetime
old_upd_time = storage.get(storage_name)
-- if update times does not equal - exiting from script
if n_upd_time ~= old_upd_time then
return
end
-- if times are equal writing 20
grp.write(scale_adress, 20)
-- wating for 20 minutes
os.sleep (20*60)
-- again checking update time
n_obj = grp.find(event.dst)
n_upd_time = n_obj.updatetime
old_upd_time = storage.get(storage_name)
-- if update times does not equal - exiting from script
if n_upd_time ~= old_upd_time then
return
end
-- if stil equal write 0
grp.write(scale_adress, 0)
end