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.

Day/Night astro object
#2
Hi alexll,

Now it possible to do easier than in mine variant. You need enter your site where device is located your coordinates, (Utilities --> Time and Date). Than sunrise and sunset times will be automatically calculated and available in scheduler. And in scheduler you can use as example sunrise time and add offset (+ or - time to switch on/off something)..

You can try to use part of my script Resident script, sleep 60 seconds):


Code:
time = os.time() latitude = 52.879110 --Site Coordinates longitude = 23.128610 --Site Coordinates sunrise, sunset = rscalc(latitude, longitude) sunrise_hour = math.floor(sunrise / 60) sunrise_minute = sunrise % 60 sunset_hour = math.floor(sunset / 60) sunset_minute = sunset % 60 sunrise_text = string.format('%02d:%02d', sunrise_hour, sunrise_minute) sunset_text = string.format('%02d:%02d', sunset_hour, sunset_minute) Day_Length = sunset - sunrise Day_Length_hour = math.floor(Day_Length / 60) Day_Length_minute = Day_Length % 60 Day_Length_text = string.format('%02d:%02d', Day_Length_hour, Day_Length_minute) grp.update('33/1/20', Day_Length_text) -- Length of the day in text way. Put in your group --log (Day_Length_hour) --log (Day_Length_minute) date = os.date('*t') now = date.hour * 60 + date.min OutsideLightOn = sunset + 60 -- Time after one hour after sunset. You can change it... OutsideLightOff = sunrise - 60 --Time one hour before sunrise. You can change it.. if now > OutsideLightOn then   OutsideLightTxt = 'Outside Light is On' -- text status of outside lighting   grp.update('33/1/11', 1) -- Switch On group of outside lighting   grp.update('33/1/12', OutsideLightTxt) --Lighting status text way   end if (now > (OutsideLightOff - 2) and now < OutsideLightOff) then   OutsideLightTxt = 'Outside Light switched Off'   --log(now)   --log(OutsideLightOn)   --log(OutsideLightOff) grp.update('33/1/11', 0) -- Switch off outside lighting   grp.update('33/1/12', OutsideLightTxt) --Text wat status of lighting end -- from 0:00 to sunrise if now < sunrise then   daynight = 'Before sunrise (Night)' -- from sunset to 23:59 elseif now > sunset then   daynight = 'After sunset (Time till midnight)' else   daynight = 'Day' end
Also you will have statuss - of the day time - Night, Day, ot time till midnight after sunset..

BR,

Alex
Reply


Messages In This Thread
Day/Night astro object - by alexll - 28.07.2020, 05:31
RE: Day/Night astro object - by AlexLV - 28.07.2020, 05:51
RE: Day/Night astro object - by alexll - 29.07.2020, 13:35

Forum Jump: