Logic Machine Forum
sunrise and sunset values - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.logicmachine.net/forumdisplay.php?fid=2)
+--- Thread: sunrise and sunset values (/showthread.php?tid=1010)

Pages: 1 2


RE: sunrise and sunset values - admin - 14.12.2018

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



RE: sunrise and sunset values - FatMax - 14.12.2018

(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)



RE: sunrise and sunset values - YOUSSEF - 29.09.2021

Hello
am trying to have twilight state (binary : sunrise = false , sunset = true) , using rscalc ,couldn't have a correct result , 
any help? tks


RE: sunrise and sunset values - admin - 29.09.2021

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



RE: sunrise and sunset values - Dan22 - 22.12.2021

Hello,

I have a request, I need to enter the time of dusk and dawn on the KNX bus, I can't do it.


RE: sunrise and sunset values - admin - 22.12.2021

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,
})



RE: sunrise and sunset values - Dan22 - 22.12.2021

Thank you, it's OK.


RE: sunrise and sunset values - Dan22 - 25.12.2021

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?


RE: sunrise and sunset values - admin - 27.12.2021

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.


RE: sunrise and sunset values - Dan22 - 28.12.2021

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.


RE: sunrise and sunset values - Daniel - 28.12.2021

Mayby you linked something to the scheduler on/off object and something is disabling it.


RE: sunrise and sunset values - Dan22 - 29.12.2021

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.


RE: sunrise and sunset values - Daniel - 29.12.2021

Did you set anything here?
   


RE: sunrise and sunset values - Dan22 - 30.12.2021

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?


RE: sunrise and sunset values - Daniel - 30.12.2021

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/showthread.php?tid=2979&pid=19193#pid19193


RE: sunrise and sunset values - Dré - 30.10.2022

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.


RE: sunrise and sunset values - admin - 31.10.2022

Use this (false is winter time, true is summer time):
Code:
dst = os.date('*t').isdst
log(dst)



RE: sunrise and sunset values - Dré - 31.10.2022

Thanks again, admin.
looks like it works