timer trigger rules - between

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

Moderator: leecollings

Post Reply
MarFan
Posts: 18
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

timer trigger rules - between

Post 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 ?
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: timer trigger rules - between

Post 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 .
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
MarFan
Posts: 18
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: timer trigger rules - between

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

Who is online

Users browsing this forum: No registered users and 1 guest