05.11.2019, 22:43
(This post was last modified: 05.11.2019, 23:01 by Erwin van der Zwart.)
Hi,
Yes, you can add a knx time and date object to the visu and a TAG to it and add this as a event based script to it that is triggered by the TAG:
When the user updates the KNX objects from the visu the script will update the controller time and date
To keep the objects in the visu up to date with the system time you can add this script as resident at 60 seconds:
BR,
Erwin
Yes, you can add a knx time and date object to the visu and a TAG to it and add this as a event based script to it that is triggered by the TAG:
Code:
if event.sender == 'us' then -- Only execute when action comes from visu
date = grp.getvalue('1/1/1')
time = grp.getvalue('1/1/2')
cmd = string.format("date -s '%d-%d-%d %d:%d:%d'", date.year, date.month, date.day, time.hour, time.minute, time.second)
os.execute(cmd)
end
To keep the objects in the visu up to date with the system time you can add this script as resident at 60 seconds:
Code:
-- get current data as table
now = os.date('*t')
-- system week day starts from sunday, convert it to knx format
wday = now.wday == 1 and 7 or now.wday - 1
-- time table
time = {
day = wday,
hour = now.hour,
minute = now.min,
second = now.sec,
}
-- date table
date = {
day = now.day,
month = now.month,
year = now.year,
}
-- write to bus
grp.write('1/1/2', time, dt.time)
grp.write('1/1/1', date, dt.date)
Erwin