Timer events more frequent then once a minute  [Solved]

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

Moderator: leecollings

Post Reply
joran
Posts: 7
Joined: Friday 22 June 2018 0:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Timer events more frequent then once a minute

Post 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
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
joran
Posts: 7
Joined: Friday 22 June 2018 0:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Timer events more frequent then once a minute

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests