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.

Sunrise sunset
#6
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:

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
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:
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)
BR,

Erwin
Reply


Messages In This Thread
Sunrise sunset - by benanderson_475 - 05.11.2019, 08:56
RE: Sunrise sunset - by admin - 05.11.2019, 09:05
RE: Sunrise sunset - by Erwin van der Zwart - 05.11.2019, 11:55
RE: Sunrise sunset - by Joep - 05.11.2019, 14:59
RE: Sunrise sunset - by benanderson_475 - 05.11.2019, 22:13
RE: Sunrise sunset - by Erwin van der Zwart - 05.11.2019, 22:43
RE: Sunrise sunset - by admin - 06.11.2019, 08:37
RE: Sunrise sunset - by Kai-Roger - 06.11.2019, 08:58
RE: Sunrise sunset - by Erwin van der Zwart - 06.11.2019, 09:37
RE: Sunrise sunset - by admin - 06.11.2019, 09:05
RE: Sunrise sunset - by Kai-Roger - 06.11.2019, 09:13
RE: Sunrise sunset - by admin - 06.11.2019, 09:14
RE: Sunrise sunset - by admin - 06.11.2019, 09:49
RE: Sunrise sunset - by Erwin van der Zwart - 06.11.2019, 09:56
RE: Sunrise sunset - by lenze90 - 28.11.2019, 21:21
RE: Sunrise sunset - by Erwin van der Zwart - 28.11.2019, 21:50
RE: Sunrise sunset - by lenze90 - 29.11.2019, 07:46
RE: Sunrise sunset - by admin - 29.11.2019, 07:49
RE: Sunrise sunset - by lenze90 - 29.11.2019, 08:13
RE: Sunrise sunset - by admin - 29.11.2019, 08:24
RE: Sunrise sunset - by GIA - 18.02.2020, 07:12
RE: Sunrise sunset - by lenze90 - 29.11.2019, 09:24
RE: Sunrise sunset - by lenze90 - 06.12.2019, 20:21
RE: Sunrise sunset - by lenze90 - 06.12.2019, 22:50
RE: Sunrise sunset - by Erwin van der Zwart - 07.12.2019, 08:21
RE: Sunrise sunset - by Joep - 14.12.2019, 14:47
RE: Sunrise sunset - by admin - 18.02.2020, 07:56
Sunrise sunset - by GIA - 18.02.2020, 07:59
RE: Sunrise sunset - by admin - 18.02.2020, 08:00
Sunrise sunset - by GIA - 18.02.2020, 08:03
RE: Sunrise sunset - by admin - 18.02.2020, 08:12
Sunrise sunset - by GIA - 18.02.2020, 08:21

Forum Jump: