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

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

Moderator: leecollings

Post Reply
User avatar
MadMedic
Posts: 31
Joined: Wednesday 26 October 2016 14:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Huizen, the Netherlands
Contact:

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

Post 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
}
Last edited by MadMedic on Saturday 20 June 2020 15:02, edited 1 time in total.
.
"Life is too short for bad coffee"
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Can't get this sunrise/sunset script triggered

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
MadMedic
Posts: 31
Joined: Wednesday 26 October 2016 14:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Huizen, the Netherlands
Contact:

Re: Can't get this sunrise/sunset script triggered

Post 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.
.
"Life is too short for bad coffee"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest