On timer trigger: which timer?  [Solved]

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

Moderator: leecollings

Post Reply
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

On timer trigger: which timer?

Post by darrepac »

Hi

I have on timer trigger at 3 times in the day (5:00, 11:30, 23:00).
In the execute part, is there a nice way to know which timer has triggered (and do corresponding actions)? and not be obliged to check the current time etc
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: On timer trigger: which timer?  [Solved]

Post by waaren »

darrepac wrote: Sunday 25 August 2019 14:01 In the execute part, is there a nice way to know which timer has triggered and not be obliged to check the current time ?
Yes; try this.

Code: Select all

local times = {'at 18:00', 'at 18:01', 'at *:03'} 

return 
{
    on = { timer = times },
    execute = function(dz, item)
        dz.log('Timer event was triggered by: ' .. item.trigger, dz.LOG_FORCE)
        if item.trigger == 'at *:03' then 
            dz.log('Found at *:03 trigger', dz.LOG_FORCE)
        end    
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
darrepac
Posts: 142
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: On timer trigger: which timer?

Post by darrepac »

great
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest