--Astroklok adressoutput = '4/0/0' --1 bit addresssunrise = '4/0/1' --14 byte ascii addresssunset = '4/0/2' --14 byte ascii addressshifttimesunrise = '4/0/3' --2 byte signed - of + 1-60 min. addressshifttimesunset = '4/0/4' --2 byte signed - of + 1-60 min. addresssunriseshifted = '4/0/5' --14 byte ascii addresssunsetshifted = '4/0/6' --14 byte ascii latitude = 51.5558 --Eindhoven longitude = 5.6903 --Eindhoven function astronomic(latitude,longitude,verschuifingsunrise,verschuifingsunset) local now = os.date('*t') local sunrise, sunset = rscalc(latitude, longitude, now) sunriseorg = string.format('%d:%.2d', math.floor(sunrise / 60), sunrise % 60) sunsetorg = string.format('%d:%.2d', math.floor(sunset / 60), sunset % 60) sunrisenew = sunrise + verschuifingsunrise sunsetnew = sunset + verschuifingsunset sunrisetime = string.format('%d:%.2d', math.floor(sunrisenew / 60), sunrisenew % 60) sunsettime = string.format('%d:%.2d', math.floor(sunsetnew / 60), sunsetnew % 60) local minutes = now.hour * 60 + now.min nowdark = minutes < sunrisenew or sunsetnew < minutes local t = {opkomst = sunriseorg, ondergang = sunsetorg, verschovenopkomst = sunrisetime, verschovenondergang = sunsettime, output = nowdark} return (t) end verschuifingsunrise = grp.getvalue(addressshifttimesunrise) -- Minuten maak negatief om 's morgens eerder uit te gaan en positief om 's morgens later uit te gaan verschuifingsunset = grp.getvalue(addressshifttimesunset) -- Minuten maak negatief om 's middags eerder aan te gaan en positief om 's middags later aan te gaan astroinfo = astronomic(latitude,longitude,verschuifingsunrise,verschuifingsunset) currentvalue = grp.getvalue(addresssunrise) if astroinfo.opkomst ~= currentvalue then grp.update(addresssunrise, astroinfo.opkomst) end currentvalue = grp.getvalue(addresssunset) if astroinfo.ondergang ~= currentvalue then grp.update(addresssunset, astroinfo.ondergang) end currentvalue = grp.getvalue(addresssunriseshifted) if astroinfo.verschovenopkomst ~= currentvalue then grp.update(addresssunriseshifted, astroinfo.verschovenopkomst) end currentvalue = grp.getvalue(addresssunsetshifted) if astroinfo.verschovenondergang ~= currentvalue then grp.update(addresssunsetshifted, astroinfo.verschovenondergang) end currentvalue = grp.getvalue(adressoutput) if astroinfo.output == true then if currentvalue == false then grp.update(adressoutput, true) end else if currentvalue == true then grp.update(adressoutput, false) end end