[SOLVED] Get sunrise and sunset time from domoticz

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
zavjah
Posts: 36
Joined: Tuesday 13 August 2019 10:20
Target OS: Raspberry Pi / ODroid
Domoticz version:

[SOLVED] Get sunrise and sunset time from domoticz

Post by zavjah »

Hi there,

I'd like to show the sunrise and sunset time that is shown e.g. on the dashboard or in the settings in in a virtual device. I've tried to calculate the time out of sunriseInMinutes but it results in a diferent time than in domoticz. I assume it is because of the location I've set in domoticz.

Thx for any hints,
Zavjah
Last edited by zavjah on Sunday 08 May 2022 13:23, edited 1 time in total.
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Get sunrise and sunset time from domoticz

Post by hoeby »

Is this where you are looking for?
Where you need to devices (Sunset and Sunrise)
Found the code on the forum, all credits to Waaren (viewtopic.php?t=26677)

Code: Select all

-- dzVents version >= 2.4.7
return {
    timer     =   { "at 00:03", "at 06:03" }, -- twice a day to be sure and 3 min past the hour because at the hour already quite busy 
     
    execute = function( dz )
        local function minutes2time(minutes)   -- integer in; string out 
            local hour      = string.format("%02d",math.floor(minutes / 60))
            local minutes   = string.format("%02d",minutes - (hour * 60))
            return (hour .. ":" .. minutes) --  string out 
        end
        
        dz.devices("Sunset").updateText("Sunset: " .. minutes2time(dz.time.sunsetInMinutes).. "\nCivil twilight end: " .. minutes2time(dz.time.civTwilightEndInMinutes or "-"))
        dz.devices("Sunrise").updateText("Sunrise: ".. minutes2time(dz.time.sunriseInMinutes).. "\nCivil twilight start: " .. minutes2time(dz.time.civTwilightStartInMinutes or "-"))
    end
}
Or have a look on this link, a lot of time options
viewtopic.php?f=72&t=28103
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
zavjah
Posts: 36
Joined: Tuesday 13 August 2019 10:20
Target OS: Raspberry Pi / ODroid
Domoticz version:

Re: Get sunrise and sunset time from domoticz

Post by zavjah »

Hi there,

thx hoeby, thx waaren, that's exactly what I was looking for. It seems my converion of minutes into hours was wrong, that's why i got different times than shown on dashboard.

Cheers,
zavjah
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: [SOLVED] Get sunrise and sunset time from domoticz

Post by Treve »

FYI, Waaren is not with us anymore. He past away.
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
Post Reply

Who is online

Users browsing this forum: Bing [Bot], heggink and 1 guest