timer trigger rules - between

Easy to use, 100% Lua-based event scripting framework.
Post Reply
MarFan
Posts: 52
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi
Domoticz version:
Contact:

timer trigger rules - between

Post by MarFan » Wednesday 16 May 2018 13:21

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 ?
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1

User avatar
waaren
Posts: 1353
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer trigger rules - between

Post by waaren » Wednesday 16 May 2018 15:35

@ 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 .
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

MarFan
Posts: 52
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: timer trigger rules - between

Post by MarFan » Wednesday 16 May 2018 16:16

@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!
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1

Post Reply

Who is online

Users browsing this forum: dannybloe and 3 guests