Sleep or Delay statement?

Moderator: leecollings

Post Reply
manjh
Posts: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Sleep or Delay statement?

Post by manjh »

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
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Sleep or Delay statement?

Post by Egregius »

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: 749
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Sleep or Delay statement?

Post by manjh »

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: 32
Joined: Saturday 25 February 2017 18:42
Target OS: Linux
Domoticz version: 2021.1
Location: Milano, Italy
Contact:

Re: Sleep or Delay statement?

Post by candrea77 »

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 Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest