Logic Machine Forum
how to use data types (3 bytes time / day)? - Printable Version

+- Logic Machine 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: how to use data types (3 bytes time / day)? (/showthread.php?tid=186)



how to use data types (3 bytes time / day)? - phongvucba - 10.01.2016

I have a problem hope everybody help  Sad .

please write one script into objects  4/4/11, to turn one lamp if the value of 4/4/11 is equal to the value you want.
Heart
example is:
15:42:00 monday, its will  turn on 1/1/1 lamp !




thank all !


RE: how to use data types (3 bytes time / day)? - buuuudzik - 10.01.2016

(10.01.2016, 09:10)phongvucba Wrote: I have a problem hope everybody help  Sad .

please write one script into objects  4/4/11, to turn one lamp if the value of 4/4/11 is equal to the value you want.
Heart
example is:
15:42:00 monday, its will  turn on 1/1/1 lamp !




thank all !


Try this:
Code:
-- object mapped to this event must have its data type set
time = event.getvalue()

time1 = {["minute"]=42, ["second"]=0, ["hour"]=15, ["day"]=1}
value1 = true -- preconfigured value of a lamp
if time.day == time1.day and time.hour == time1.hour and time.minute == time1.minute then
 grp.write('1/1/1', value1) -- change the lamp to the preconfigured value
else
 -- do nothing
end

But the best way to the time controlling in LM is shedulers or sheduled script.


RE: how to use data types (3 bytes time / day)? - admin - 11.01.2016

Yes, you should use Schedulers for this task, it's more flexible and user-friendly than scripts.


RE: how to use data types (3 bytes time / day)? - phongvucba - 11.01.2016

thank admin and buuuudzik !!<3