dzVents - Possible to use a variable for a timed event

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

Moderator: leecollings

Inso80
Posts: 12
Joined: Thursday 17 May 2018 13:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: dzVents - Possible to use a variable for a timed event

Post by Inso80 »

waaren wrote: Tuesday 18 September 2018 0:46 You are close...

Code: Select all

return {
       
     on = { 
        timer = {  function(domoticz)
                     return domoticz.devices('Texttest').text == os.date("%H")
                   end
        }},

        execute = function(domoticz)
        print ( "Executing!!!")
        
    end
}
But would it not be less complicated to use timer = { "every minute" }, and a helper function in the execute = section as described here ?
Doh, the brackets :oops: thanks :D

It would be less complicated, for sure :) . Problem is, on "many" posts I´ve read people "complaining" about the need to clean up their scripts to get everything running smooth, so I decided to make it as fast as possible from the bones ( I plan to realize / already have done a lot of stuff with Domoticz, f.e. motion sensors, temperature, lux, change light level according to lux and time, passing the WS2812B-code to the MySensor-nodes, passing temperature to displaynodes, and so on).
Therefore, I tried to stop the script as soon as possible. Calling a helper function (which seems to be a method call according to C++, available from all scripts?) seemed to need "a lot" more running time. Alone putting my time comparison into an if-statement feeled like not to be a good way - the script starts and has to be handled "completely", every minute.
On the other hand, you seem to have a lot of experience with Domoticz and DzVents - do I overstep the mark? Is it unproblematic to have a lot of stuff running "simultaniously", calling helper functions for a handful of time-based scripts every minute and so on?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dzVents - Possible to use a variable for a timed event

Post by waaren »

Inso80 wrote: Tuesday 18 September 2018 9:45 ... Is it unproblematic to have a lot of stuff running "simultaniously", calling helper functions for a handful of time-based scripts every minute and so on?
Walltime for executing a helper function on my (Raspberry Pi-3) system is around 0.001 seconds. For me that is negligible
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest