Page 1 of 1

timer trigger rules - between

Posted: Wednesday 16 May 2018 13:21
by MarFan
I try to create a new script that runs every minute between 10:00 and sunset. But when I use the following code, nothing is happening.

Code: Select all

    on = {
        timer = {'every 1 minute between 10:00 and sunset'}
    }
When I use as a test :

Code: Select all

timer = {'every 2 minutes between 12:30 and 13:00'}
The script keeps working :
2018-05-16 13:14:00.517 dzVents: Info: Sunscreen: ------ Start external script: sunscreen.lua:, trigger: every 2 minutes between 12:30 and 13:00


The 'normal'

Code: Select all

'every 1 minute at 12:30-13:00'
is working, but I cannot have the sunset combined in this syntax?

What is wrong with the between syntax ?

Re: timer trigger rules - between

Posted: Wednesday 16 May 2018 15:35
by waaren
@ MarFan, I don't think you can combine the sunset and time in the on section like you want. A workaround could be
Spoiler: show

Code: Select all

--[[ 
 timerTest.lua (dzVents > 2.3 )
 ]]-- 

return {

on = { timer = {'between sunrise and sunset'} },
    
            logging =   {   level = domoticz.LOG_INFO,                      
                            marker = "timerTest" },                           
    
    execute = function(dz,_)
        
        if ( dz.time.matchesRule("at 10:00-23:59") ) then
            dz.log("Time to do stuff",dz.LOG_INFO)
        else
            dz.log("Now it is not the time to do stuff",dz.LOG_INFO)
        end
    end
}
the condition in the on = section takes care that the script won't be triggered before sunrise or after sunset and the matchesRule condition ensure that the part between if and else is only executed after 10:00 .

Re: timer trigger rules - between

Posted: Wednesday 16 May 2018 16:16
by MarFan
@Waaren, thank you for your answer.
I found out that the between is not working on the stable version. On my beta test version it is working.
Thank you for the workaround for in stable!