Wrong timeofday daytime,nighttime,...

Moderator: leecollings

Post Reply
PVuser
Posts: 33
Joined: Monday 30 March 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: DE
Contact:

Wrong timeofday daytime,nighttime,...

Post 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
Last edited by PVuser on Friday 03 April 2020 8:54, edited 1 time in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Wrong timeofday daytime,nighttime,...

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
PVuser
Posts: 33
Joined: Monday 30 March 2020 19:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: DE
Contact:

Re: Wrong timeofday daytime,nighttime,...

Post by PVuser »

Now I understand and it works - Many thanks :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest