Latency issue

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
blackhawk
Posts: 5
Joined: Wednesday 27 July 2016 13:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5406
Location: Paris Area, France
Contact:

Latency issue

Post by blackhawk »

Hi everyone,

I am a new user here, but I've been using Domoticz for a few weeks now, and I have to admit I fell in love with it :)

I have started to integrate my home automation system with Domoticz and MySensors, but I am now facing an issue.
I have placed in my bedroom and my bathroom some PIRs and relays to switch on the light automatically, and this is nearly working fine.
The reason why I say "nearly" is because there is a random latency between the detection by the PIR and the actual activation of the relay.
I've checked the logs on my Raspberry, and I can see the latency.

Below are the logs when I play with my Android app (Domoticz Lite). You can the delay between the command and the actual action. The delay you can see here is a bit longer than what I really face in this case, but this cannot be considered as "instant".

Code: Select all

2016-08-02 12:19:05.501  User: bh initiated a switch command
2016-08-02 12:19:06.404  (Huzzah) Lighting 2 (Salle de bain / Spots)
2016-08-02 12:19:11.380  User: bh initiated a switch command
2016-08-02 12:19:12.383  (Huzzah) Lighting 2 (Salle de bain / Spots)
2016-08-02 12:19:17.800  User: bh initiated a switch command
2016-08-02 12:19:18.403  (Huzzah) Lighting 2 (Salle de bain / Lumière)
2016-08-02 12:19:23.021  User: bh initiated a switch command
2016-08-02 12:19:23.428  (Huzzah) Lighting 2 (Salle de bain / Lumière)
2016-08-02 12:19:29.148  User: bh initiated a switch command
2016-08-02 12:19:29.450  (Huzzah) Lighting 2 (Salle de bain / Spots)
2016-08-02 12:19:31.802  User: bh initiated a switch command
2016-08-02 12:19:32.404  (Huzzah) Lighting 2 (Salle de bain / Spots)
2016-08-02 12:19:35.067  User: bh initiated a switch command
2016-08-02 12:19:35.469  (Huzzah) Lighting 2 (Salle de bain / Spots)
2016-08-02 12:19:37.545  User: bh initiated a switch command
2016-08-02 12:19:38.447  (Huzzah) Lighting 2 (Salle de bain / Spots)
2016-08-02 12:19:43.442  User: bh initiated a scene/group command
2016-08-02 12:19:43.446  Activating Scene/Group: [Lumières salle de bain]
2016-08-02 12:19:43.448  Activating Scene/Group Device: Salle de bain / Lumière (On)
2016-08-02 12:19:44.450  (Huzzah) Lighting 2 (Salle de bain / Lumière)
2016-08-02 12:19:44.542  Activating Scene/Group Device: Salle de bain / Spots (On)
2016-08-02 12:19:45.444  (Huzzah) Lighting 2 (Salle de bain / Spots)
2016-08-02 12:19:48.692  User: bh initiated a scene/group command
2016-08-02 12:19:48.696  Activating Scene/Group: [Lumières salle de bain]
2016-08-02 12:19:48.698  Activating Scene/Group Device: Salle de bain / Lumière (Off)
2016-08-02 12:19:49.400  (Huzzah) Lighting 2 (Salle de bain / Lumière)
2016-08-02 12:19:49.491  Activating Scene/Group Device: Salle de bain / Spots (Off)
2016-08-02 12:19:50.381  (Huzzah) Lighting 2 (Salle de bain / Spots)
Below are the logs when I walk in the bedroom.
You can see there is the roof light ("Plafonnier") and some LEDs, which are on some buttons my wife and I press when we go to bed or wake up.

Code: Select all

2016-08-02 12:22:10.456  LUA: Bedroom luminosity handler: luminosity is low, turning on roof light
2016-08-02 12:22:10.458  EventSystem: Script event triggered: Bedroom luminosity handler
2016-08-02 12:22:10.427  (Huzzah) Lighting 2 (Chambre / Détecteur de mouvement)
2016-08-02 12:22:11.502  (Huzzah) Lighting 2 (Chambre / Boutons / LEDs boutons)
2016-08-02 12:22:12.441  (Huzzah) Lighting 2 (Chambre / Plafonnier)
2016-08-02 12:22:49.465  LUA: Bedroom luminosity handler: luminosity is high, turning off roof light
2016-08-02 12:22:49.467  EventSystem: Script event triggered: Bedroom luminosity handler
2016-08-02 12:22:49.439  (Huzzah) Lux (Chambre / Capteur de luminosité)
2016-08-02 12:22:50.523  (Huzzah) Lighting 2 (Chambre / Plafonnier)
2016-08-02 12:22:51.467  (Huzzah) Lighting 2 (Chambre / Boutons / LEDs boutons)
Some information regarding my setup:
- Domoticz v3.5382 running on a Raspberry Pi B2
- MySensors Gateway 2.0.0 running on a ESP8266 (Adafruit Huzzah to be more specific)
- Various MySensors nodes based on Atmega328p (5 nodes so far)

Transmition details:
- PIRs: my nodes are set to only transmit when their state changes
- Temp/Hum/Lux sensors: they transmit every 15 minutes, except for the lux sensor which also transmits when a change >50lux occurs.
From my point of view, there should not be any network congestion.

As I write this post, I wonder if this is a Domoticz issue, a MySensors issue, or a Domoticz/MySensors communication issue...

Still, I am very happy with my setup, but my wife isn't much because of the delay (which can, from time to time, exceed 2 seconds (I have no logs for that, but I've seen it)).

Can anyone help me with this issue, or tell me where to look?

Many thanks!

EDIT: I think this was unclear in my post, but the delay has been there from the beginning. I just didn't realize how "important" it would be in real life usage.
blackhawk
Posts: 5
Joined: Wednesday 27 July 2016 13:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5406
Location: Paris Area, France
Contact:

Re: Latency issue

Post by blackhawk »

I have a LED on the nodes with the PIRs, and I tried the following configuration to measure the delay between sending a piece an information and receiving a command :
When motion is detected, light up the LED
When a command is received, shut off the LED

In this configuration, I have about 1 second (sometimes a bit more, sometimes a bit less) before the command arrives.
I know that a small latency is completely normal, but I figure that 1 second is long (I expect something below 500ms at least).

From what I have been able to see by myself so far, it appears to be more a Domoticz than a MySensors issue.

Any help or piece of information would be very appreciated! :)
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Latency issue

Post by Egregius »

What script or action are you using to switch the light on?
With on/of actions I also had about 1 sec delay.
Since I moved everything to one script I have less than 100msec delay:


at .002 the signal of the pir comes in, at .075 my script has already run and at .099 the switch is switched.
2016-08-02 17:09:17.002 (ZWAVE) Light/Switch (pirkeuken)
2016-08-02 17:09:17.075 Switch 491 (Wasbak) ON
2016-08-02 17:09:17.099 User: Admin initiated a switch command
2016-08-02 17:09:17.099 OpenZWave: Domoticz has send a Switch command! NodeID: 61 (0x3d)
2016-08-02 17:09:17.099 (ZWAVE) Light/Switch (wasbak)
blackhawk
Posts: 5
Joined: Wednesday 27 July 2016 13:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5406
Location: Paris Area, France
Contact:

Re: Latency issue

Post by blackhawk »

I have some basic Lua scripts that perform on/off action, like you mention.

I will try your solution and let you know.

Thanks!
blackhawk
Posts: 5
Joined: Wednesday 27 July 2016 13:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5406
Location: Paris Area, France
Contact:

Re: Latency issue

Post by blackhawk »

I've realized a basic Node.js script which does what your PHP script does (decode and analyze the data sent by the Lua script, and call the API), but I have the same results as before so far.
I disabled the Lua scripts during my tests.
I will try to look deeper into it, but it doesn't look like it has an impact on the latency for now.

EDIT: it appears to be faster with PHP, I will check it out.
blackhawk
Posts: 5
Joined: Wednesday 27 July 2016 13:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5406
Location: Paris Area, France
Contact:

Re: Latency issue

Post by blackhawk »

So I made a basic PHP script based on your example, and here are my results:

Code: Select all

2016-08-03 01:12:36.730 (Huzzah) Lighting 2 (Chambre / Détecteur de mouvement)
2016-08-03 01:12:36.875 User: Admin initiated a switch command
2016-08-03 01:12:37.777 (Huzzah) Lighting 2 (Chambre / Plafonnier)

Code: Select all

2016-08-03 01:16:35.768 (Huzzah) Lighting 2 (Chambre / Détecteur de mouvement)
2016-08-03 01:16:35.944 User: Admin initiated a switch command
2016-08-03 01:16:36.768 (Huzzah) Lux (Chambre / Capteur de luminosité)
From what I can observe at my place, it is a little bit faster, and less random.
However, it is still a bit slower than what I expect.

@Egregius: I see that you are using a Synology NAS, which is way more powerful than my small Pi :)
So I guess this may be the reason why you have those response delays, isn't it?

Does anyone ever faced similar issues?
renerene
Posts: 351
Joined: Wednesday 03 August 2016 11:36
Target OS: -
Domoticz version:
Contact:

Re: Latency issue

Post by renerene »

Today I found this interesting post and now I'm in the middle of getting it to work on my Pi.

My current situation is Lua (most) + blockly. The response of some switches is faster than others:
- AWMR-230 (kaku switch) + ASUN650 (kaku screen) via LUA takes 1.5 .. 2 seconds
- kaku PIR switch: also slow via Pi/Domoticz; direct connection from PIR to light is fast
- AWST-8802 (kaku switch) + Fibaro Roller Shutter 2 (Zwave) takes less 0.5 sec to react
- When using the Domoticz dashboard webinterface, action take place almost immediatly, no latency.

1) did you have latency problems with ALL devices? How fast was your webinterface dashboard?

Questions regarding http://egregius.be/2016/lua-pass2php-v2-0/:
1) Which PHP package do I need to install? Just "sudo apt-get install php5-cli"?
2) is this correct result of an extra added debug line?
print ('/home/pi/domoticz/scripts/php/test.php "'..changed..'" "'..devices..'" "'..idx..'" "'..lastupdate..'" &')
result: /home/pi/domoticz/scripts/php/test.php "bnVsbA==" "eyIyMjB2IHR1aW5odWlzIjoiT2ZmIiwiQWxhcm0gTGV2ZWwgT04vT0ZGIjoiT2ZmIiwiQ ... [8 lines of symbols]
3) Do i need to perform 'chmod +x' on the test.php file? Other files too?
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Latency issue

Post by Egregius »

renerene wrote: 1) did you have latency problems with ALL devices? How fast was your webinterface dashboard?

2) Questions regarding http://egregius.be/2016/lua-pass2php-v2-0/:
1) If I remember correctly yes, there was always a delay of approx. 1 sec.
2) See http://www.domoticz.com/forum/viewtopic ... 826#p94826
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest