Page 1 of 1

sleep command dzVents

Posted: Friday 30 March 2018 11:52
by poudenes
Hi All,

I have add all scripts into 1. Easier way to manage local variables and device IDX. But now i see some problems.
It is working so fast that multiple IF statements are runs when its not good.

Is there a way to let the script sleep for een certain time ms or sec before it goes to next if or else if statement?

If this is possible the if statement that must run all commands can be done wait for 1 sec then goto the next.
The next if statement will only act if everything in the if is true or false.

On Internet see lot of options and this one seems only to work but don't know:

Code: Select all

function sleep (a) 
    local sec = tonumber(os.clock() + a); 
    while (os.clock() < sec) do 
    end 
end
But when i add this at end of the if statment i see that after 1 sec for example the commands are running. Not before and then the sleep action.

Cheers,
Peter

Re: sleep command dzVents

Posted: Friday 30 March 2018 14:05
by waaren
If the reason for the sleep is to base your logic on activated changes in domoticz devices then please be aware that dzVents ( and other event scripting systems ) send the commands back to domoticz after the script has finished. So the device state inside your script doesn't change.
So waiting for something to happen in domoticz inside your script is not working.

Re: sleep command dzVents

Posted: Friday 30 March 2018 14:08
by poudenes
Thanks for the info.

As writing and look at the script i see i have some scene switches into the devices = {}
That is not ok. Removed them and now the whole loop problems is gone.

Didn't saw the problem until now... grrr :lol:

Re: sleep command dzVents

Posted: Friday 30 March 2018 19:33
by dannybloe
I really advice against putting everything in one script.

Re: sleep command dzVents

Posted: Friday 30 March 2018 19:40
by poudenes
And why? Because managing is much easier now... The script is working. Have split it in "by device" "nighttime ""daytime" and "every minute"


Verzonden vanaf mijn iPhone met Tapatalk Pro