Page 1 of 1

Sunrise time in text dummy

Posted: Wednesday 23 January 2019 20:24
by maceddy
Just for the fun of it:

Every morning I get a push message with tje current temperature. That works fine.
I would like, just for the fun, to include the sunrise time.

Is there a way to put the sunrise time in a text dummy? I tried with Set dummy to sunrise, but I get 'unknown comparevariable logic_sunrisesunset' as content in the text dummy.. I think there is some conversion to be done.. Is that even possible in blockly?

Re: Sunrise time in text dummy

Posted: Thursday 24 January 2019 1:10
by waaren
I don't think it can be done in Blockly.
In dzVents it would look like the script below.

If you are not yet familiar with dzvents then please look at the 10 lines using dzVents with Domoticz for an intro to dzVents and howto get this script active in domoticz.

Before activating this script you need two text sensors; named Sunset and Sunrise.

Code: Select all

return {
    on          =   {   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(minutes2time(dz.time.sunsetInMinutes))
        dz.devices("Sunrise").updateText(minutes2time(dz.time.sunriseInMinutes))
    end
}

Re: Sunrise time in text dummy

Posted: Thursday 24 January 2019 15:20
by alanlsmith
or in Lua if you fancy it.

Just change text device idx & time to run if you want to.

script_time_displaysunset.lua

Code: Select all

commandArray = {}

local houroftheday = tonumber(os.date("%H"))
local minutesofthehour = tonumber(os.date("%M"))
local timeinminutes = (houroftheday *60) + minutesofthehour
local dawn = timeofday['SunriseInMinutes']
local dawnminute = dawn % 60
local dawnhour = (dawn - dawnminute) /60

--Change to suit--
local sunsetdeviceIDX = 508 --idx of text device

if(timeinminutes == 180) then -- 03:00 --Time to run script

	displaysunset = 'Sunrise: ' ..dawnhour.. ':' ..dawnminute
	commandArray[#commandArray+1] = {['UpdateDevice'] = sunsetdeviceIDX.. '|0|' ..displaysunset}

end

Re: Sunrise time in text dummy

Posted: Wednesday 22 May 2019 13:38
by Jubbes
is it possible to include civil twilight start and civil twilight end in the dzvents code?

Jubbes

Re: Sunrise time in text dummy

Posted: Wednesday 22 May 2019 14:20
by waaren
Jubbes wrote: Wednesday 22 May 2019 13:38 is it possible to include civil twilight start and civil twilight end in the dzvents code?
Sure. (available in dzVents version >= 2.4.7)

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
}

Re: Sunrise time in text dummy

Posted: Thursday 23 May 2019 18:03
by Jubbes
Perfect waaren,
i have one button for one astro event:

dz.devices("Civil Twilight End").updateText(minutes2time(dz.time.civTwilightEndInMinutes))
dz.devices("Civil Twilight Start").updateText(minutes2time(dz.time.civTwilightStartInMinutes))
dz.devices("Sunset").updateText(minutes2time(dz.time.sunsetInMinutes))
dz.devices("Sunrise").updateText(minutes2time(dz.time.sunriseInMinutes))

is it possible to add nautical twilight start/end and astronomical twilight start/end for four buttons?

Thank you,
jubbes

Re: Sunrise time in text dummy

Posted: Friday 24 May 2019 9:31
by Jubbes
I mean what is the short Name from Nautical and Astronimical Twilight for the Script like civTwilightEnd ?

Re: Sunrise time in text dummy

Posted: Friday 24 May 2019 10:04
by waaren
Jubbes wrote: Friday 24 May 2019 9:31 I mean what is the short Name from Nautical and Astronimical Twilight for the Script like civTwilightEnd ?
There is none in dzVents but I am trying to get it in another way. Script should be available today.

Re: Sunrise time in text dummy

Posted: Friday 24 May 2019 10:07
by Jubbes
2.4.19

Re: Sunrise time in text dummy

Posted: Friday 24 May 2019 14:20
by waaren
Jubbes wrote: Friday 24 May 2019 10:072.4.19
Posted the revised script in dzVents examples

Re: Sunrise time in text dummy

Posted: Friday 24 May 2019 17:30
by Jubbes
Cool, thank you.