Page 1 of 1

On timer trigger: which timer?

Posted: Sunday 25 August 2019 14:01
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

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

Posted: Sunday 25 August 2019 18:05
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
}

Re: On timer trigger: which timer?

Posted: Sunday 25 August 2019 18:15
by darrepac
great