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 and sunset values
#21
rscalc return values are in minutes starting from 0:00. You can convert these value to timestamps like this:
Code:
date = os.date('*t')
date.hour = 0
date.sec = 0
date.min = 0

-- timestamp of 0:00 today
time = os.time(date)

sunrise_time = time + sunrise * 60
sunset_time = time + sunset * 60
Reply
#22
(14.12.2018, 09:41)admin Wrote: rscalc return values are in minutes starting from 0:00. You can convert these value to timestamps like this:
Code:
date = os.date('*t')
date.hour = 0
date.sec = 0
date.min = 0

-- timestamp of 0:00 today
time = os.time(date)

sunrise_time = time + sunrise * 60
sunset_time = time + sunset * 60

That was even less code than what I thought. Thank you!


Code:
require('uci')

latitude = uci.get('genohm-scada.core.latitude')
latitude = tonumber(latitude)

longitude = uci.get('genohm-scada.core.longitude')
longitude = tonumber(longitude)

sunrise, sunset = rscalc(latitude, longitude)

date = os.date('*t')
date.hour = 0
date.sec = 0
date.min = 0

-- timestamp of 0:00 today
time = os.time(date)

sunrise_time = time + sunrise * 60
sunset_time = time + sunset * 60

log('Sunrise: ' ..sunrise_time)
log('Sunset: ' ..sunset_time)
Reply
#23
Hello
am trying to have twilight state (binary : sunrise = false , sunset = true) , using rscalc ,couldn't have a correct result , 
any help? tks
Reply
#24
rscalc returns time in minutes since midnight. You can get current time in minutes like this then compare it using < and >:
Code:
date = os.date('*t')
mins = date.hour * 60 + date.min
Reply
#25
Hello,

I have a request, I need to enter the time of dusk and dawn on the KNX bus, I can't do it.
Reply
#26
Change latitude, longitude and sending groups as needed:
Code:
latitude = 12
longitude = 23

sunrise, sunset = rscalc(latitude, longitude)

grp.write('1/1/1', {
  hour = math.floor(sunrise / 60),
  min = sunrise % 60,
  sec = 0,
})

grp.write('1/1/2', {
  hour = math.floor(sunset / 60),
  min = sunset % 60,
  sec = 0,
})
Reply
#27
Thank you, it's OK.
Reply
#28
Hello,

I have a problem controlling the lights from the scheduler when they are controlled by sunset / sunrise. When it is controlled by time, it is not a problem. Is there a way to solve this?
Reply
#29
What is the problem exactly? Do you have correct date/time and timezone set in Utilities > Date & time? For better precision you have to specify exact coordinates.
Reply
#30
The problem is not in the time zone, I entered the coordinates manually. According to the script that writes sunrise and sunset on the KNX bus, the coordinates are OK.
The problem is that the scheduler always shuts down after sunrise. When the scheduler is active, it does not always activate at sunset.
I don't know why the scheduler shuts down. I don't know why it doesn't activate anything at sunset. The event is always activated at sunrise.
Reply
#31
Mayby you linked something to the scheduler on/off object and something is disabling it.
------------------------------
Ctrl+F5
Reply
#32
I have nothing connected to the planner. I can write a script to activate the scheduler, but I don't know where to find the required scheduler in the scripts.
Other planners work properly, but are not set for sunrise and sunset, only for time.
Reply
#33
Did you set anything here?
   
------------------------------
Ctrl+F5
Reply
#34
I didn't set anything there.
Yesterday I removed this scheduler and added it again with a different name and it still works fine.
Can I use a scheduler event for a script?
Reply
#35
Scheduler is writing to a object, event based script can run based on this action. Don't think scheduler has dedicated source address, it is probably us = user interface / visualization. Just log your object and you will see in logs.
https://forum.logicmachine.net/showthrea...3#pid19193
------------------------------
Ctrl+F5
Reply
#36
Does have anyone a solution how to calculate if it is summertime or wintertime
I live in Holland and we use the 'Central European Time (CET)' timezone.
Reply
#37
Use this (false is winter time, true is summer time):
Code:
dst = os.date('*t').isdst
log(dst)
Reply
#38
Thanks again, admin.
looks like it works
Reply


Forum Jump: