Example: Change time/date from LUA script on LM2
How to set internal time/date from LUA script, which would give the possibility to keep it updated with internet (with a wget for example; or allowing NTP protocol on Ethernet)?
Note! NTP is enabled on LM2 by default and once connected to Internet, LM2 time is being updated automatically.
Add the following function in User Function Library and call it with specific parameters whenever you want to change time and date parameters.
- function setdate(year, mon, day, hour, min, sec)
- os.execute(string.format("date -s '%d-%d-%d %d:%d:%d'", year, mon, day, hour, min, sec))
- os.execute('hwclock -u -w')
Update LogicMachine system time from KNX telegram
You will need two objects – date and time.
- date = grp.getvalue('date_object')
- time = grp.getvalue('time_object')
- setdate(date.year, date.month, date.day, time.hour, time.minute, time.second)