Page 1 of 1

Timer events more frequent then once a minute

Posted: Monday 29 July 2019 22:53
by joran
Hello,

I'm trying to call a python script using dzVents, this works great but there is one problem. I want to call the script once every 10 seconds, is this possible using the timer trigger? I read on the wiki that dzVents scans the timer events only once a minute but I was wondering if someone found a workaround for this. If this isn't possible I will be making a custom plug-in but I would like to use dzVents. I don't want to use a dummy device for triggering the script. I hope you can help me.

code:
Spoiler: show
return {
on = {
timer = { 'every minute' }

},
execute = function(domoticz, device)
local cmd1 = ('/home/pi/domoticz/scripts/adc.py 72 0 32')
domoticz.log('adc read')
os.execute(cmd1)
end
}

Re: Timer events more frequent then once a minute  [Solved]

Posted: Monday 29 July 2019 23:27
by waaren
joran wrote: Monday 29 July 2019 22:53 I want to call the script once every 10 seconds, is this possible using the timer trigger?
Not with ONLY a timer. This a restriction from the domoticz event system.
I don't want to use a dummy device for triggering the script. I hope you can help me.
This should do it

Code: Select all

local scriptTrigger = 'frequentFlyer'
return 
{
    on = 
    {
        timer = { 'every 5 minutes' },
        
        httpResponses = { scriptTrigger },
    },

    execute = function(dz, item)
    
        if item.isTimer then
            url = dz.settings['Domoticz url'] .. "/json.htm?type=command&param=addlogmessage&message=" .. scriptTrigger .. "_script_trigger"
            for seconds = 10, 290, 10 do -- start with 10 step 10 until 290
                dz.openURL({url = url, callback = scriptTrigger }).afterSec(seconds)
            end
        end
    
        local cmd1 = ('/home/pi/domoticz/scripts/adc.py 72 0 32')
        dz.log('adc read')
        os.execute(cmd1) 
    
    end
}

Re: Timer events more frequent then once a minute

Posted: Tuesday 30 July 2019 23:25
by joran
This works great, thank you so much. This saves me a lot of work, I had to make a custom plugin if this wasn't an option. This is certainly something to keep in mind when doing other implementations.