Sleep or Delay statement?

manjh
Posts: 147
Joined: Saturday 27 February 2016 13:49
Target OS: Windows
Domoticz version:
Contact:

Sleep or Delay statement?

Postby manjh » Friday 10 March 2017 1:45

I use several PIR sensors to switch on lights. With a recent Domoticz update I suddenly find that the lights donot switch on any more. After a lot of searching, I am beginning to suspect that the PIR sensors send multiple signals. Domoticz recognizes the first and starts my script, where a KAKU switch is activated to switch the lights on. I think this happens while the PIR sensor is still putting out signals.

I have two questions.
1. is there a logical explanaition why this has worked OK, and now suddenly not? Has Domoticz become faster in the last update?
2. what can I do to delay the processing? I was looking for a "sleep" or "delay", but cannot find anything. Ideally I would want to specify a sleeptime in milliseconds.

Thanks in advance...
Hans

Egregius
Posts: 2080
Joined: Thursday 09 April 2015 12:19
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Beitem, BE
Contact:

Re: Sleep or Delay statement?

Postby Egregius » Friday 10 March 2017 4:36

In PHP you have sleep() for seconds and usleep() for microseconds, but hey, this is the lua section so I didn't say anything :lol:

manjh
Posts: 147
Joined: Saturday 27 February 2016 13:49
Target OS: Windows
Domoticz version:
Contact:

Re: Sleep or Delay statement?

Postby manjh » Monday 20 March 2017 23:44

Egregius wrote:In PHP you have sleep() for seconds and usleep() for microseconds, but hey, this is the lua section so I didn't say anything :lol:

Yeah, well... if we had an easy way to insert Assembler into Domoticz.... but I want to stick to LUA here.
Hans

candrea77
Posts: 16
Joined: Saturday 25 February 2017 19:42
Target OS: Linux
Domoticz version: 3.7277
Location: Milano, Italy
Contact:

Re: Sleep or Delay statement?

Postby candrea77 » Tuesday 21 March 2017 23:38

You can use this simple function ....

Code: Select all

function sleep(n)
    os.execute("sleep " .. tonumber(n))
end



Regards
Sorry for any spelling mistake, English is not my native language.

DomoticZ running on Debian 8.7 Jessie , open-zwave and open-zwave-control-panel


Return to “LUA”

Who is online

Users browsing this forum: No registered users and 1 guest