Page 2 of 2

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

Posted: Tuesday 18 September 2018 9:45
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?

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

Posted: Tuesday 18 September 2018 16:37
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