Page 1 of 1

Can't get this sunrise/sunset script triggered [SOLVED]

Posted: Saturday 20 June 2020 14:07
by MadMedic
Hi guys,

A while ago I found this sunset/sunrise dz vents script in this forum,
but doesn't matter what I try, I can't seem to get this script triggered.
No mentioning in logs that is has been triggered too.

Perhaps someone can help me, please ? Can it be a timer issue ?

(and yes, I activated DZ vents on the settingspage.
And the names of the textdevices are the exact same as in this script)

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: Can't get this sunrise/sunset script triggered

Posted: Saturday 20 June 2020 14:54
by waaren
MadMedic wrote: Saturday 20 June 2020 14:07 A while ago I found this sunset/sunrise dz vents script in this forum,
but doesn't matter what I try, I can't seem to get this script triggered.
In this copy of the script you used "at 00.03" as a trigger time. The notation should be "at 00:03"
If you modify and save the script do you see that it is saved in the log ?
I added some logging to see what happens when the script executes.

Code: Select all

return
{
    on =
    {
        timer =
        {
            'at 00:03',
            'at 06:03'
        },
    },

    logging =
    {
        logging = domoticz.LOG_DEBUG,
        marker = 'times',
    },

    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: Can't get this sunrise/sunset script triggered

Posted: Saturday 20 June 2020 15:01
by MadMedic
Hi Waaren (to the rescue again)

Already found this wrong time format too using the DZvents timer documentation on Domoticz.com (RTFM, Medic)
So you're totally right, its working now.. Thanks anyway for your time. ^5

But for the following users of this script perhaps it is good to know.