Page 1 of 1

Wrong timeofday daytime,nighttime,...

Posted: Friday 03 April 2020 8:42
by PVuser
What's wrong in my mind? How to use it?

I have set the right location in settings and get the right times at the dashboard and with json:

Code: Select all

/json.htm?type=command&param=getSunRiseSet

Code: Select all

AstrTwilightEnd	"21:42"
AstrTwilightStart	"04:51"
CivTwilightEnd	"20:21"
CivTwilightStart	"06:12"
DayLength	"13:03"
NautTwilightEnd	"21:00"
NautTwilightStart	"05:33"
ServerTime	"2020-04-03 08:26:40"
SunAtSouth	"13:17"
Sunrise	"06:45"
Sunset	"19:48"
status	"OK"
title	"getSunRiseSet"
But if I try to use it in lua:

Code: Select all

        print(timeofday['Daytime'])
        print('SunriseInMinutes '..timeofday['SunriseInMinutes'] )
i get wrong times:

Code: Select all

 2020-04-03 08:29:39.444 Status: LUA: Nighttime
2020-04-03 08:29:39.444 Status: LUA: SunriseInMinutes 405
...and the SunRiseInMinutes doesn't change the value!?

What I want is to run a script only when it is bright outside

Re: Wrong timeofday daytime,nighttime,...

Posted: Friday 03 April 2020 8:48
by waaren
PVuser wrote: Friday 03 April 2020 8:42 What's wrong in my mind? How to use it?
Sunrise "06:45"
2020-04-03 08:29:39.444 Status: LUA: SunriseInMinutes 405
SunriseInMinutes 405 = 6 hours * 60 + 45 is 6:45

This variable will only change once a day at midnight. It contains todays sunrisetime converted to minutes.
If you want to compute with it you also need the current time in minutes which is changed every minute.

Re: Wrong timeofday daytime,nighttime,...

Posted: Friday 03 April 2020 9:14
by PVuser
Now I understand and it works - Many thanks :-)