Can I detect Sunrise and Sunset in a LUA script? I realize it is easy in Blockly, but I can't figure it out in LUA.
I found timeofday['SunriseInMinutes'] and timeofday['SunsetInMinutes'], but how do I get the time of day in minutes to compare with?
Sunrise/sunset in LUA
Moderator: leecollings
- jvdz
- Posts: 2445
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Sunrise/sunset in LUA
Something like this:
Jos
Code: Select all
minutesnow = timenow.min + timenow.hour * 60
if (minutesnow == timeofday['SunsetInMinutes']+2) then
-- this runs 2 minutes after SunSet
end
-
manjh
- Posts: 859
- Joined: Saturday 27 February 2016 12:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: NL
- Contact:
Re: Sunrise/sunset in LUA
you beat me to it. I figured out:
test = os.date("%H") * 60 + os.date("%M")
Gives me the time of day in minutes. Really simple, actually...
test = os.date("%H") * 60 + os.date("%M")
Gives me the time of day in minutes. Really simple, actually...
Hans
Who is online
Users browsing this forum: No registered users and 1 guest