Lag in Virtual Swtiches Topic is solved

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post
Post Reply
matv
Posts: 22
Joined: Sunday 08 January 2017 19:26
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: EU
Contact:

Lag in Virtual Swtiches

Post by matv » Wednesday 11 January 2017 16:38

Version: 3.5877
Platform: Raspberry Pi v 3
Description:
Hi there,
I was wondering if the lag I am experiencing is normal.

- When I SSH from my MacBook to my Pi and execute a script* to turn on/off my lights, it works instantaneously.

- When I execute the same script* from a Dummy Virtual Switch in Domoticz, the lag is about 1 second before my lights respond.

It doens't bother me so much but it would be nice if I could somehow decrease the lag.
P.S. I am using the word lag because delay is a setting for switches. Mine is set to 0.

*) Applies to both https://github.com/bwydoogh/domoticz-scripts and https://github.com/LumKitty/MiLight3 .

User avatar
Egregius
Posts: 2416
Joined: Thursday 09 April 2015 12:19
Target OS: Raspberry Pi
Domoticz version: BetaRPi2
Location: Beitem, BE
Contact:

Re: Lag in Virtual Swtiches

Post by Egregius » Wednesday 11 January 2017 16:46

That's indeed a known issue. On/Off actions take approx 850msec to execute.
That's why I created LUA pass2php. With that script the 'lag' is on my system 20 msec, wich is lightning fast :D

matv
Posts: 22
Joined: Sunday 08 January 2017 19:26
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: EU
Contact:

Re: Lag in Virtual Swtiches

Post by matv » Wednesday 11 January 2017 16:55

Thanks for your timely and accurate response, Egregius!
I will look into your script.

Hopefully one day the lag in the stable version will be somewhat shorter :)

User avatar
Egregius
Posts: 2416
Joined: Thursday 09 April 2015 12:19
Target OS: Raspberry Pi
Domoticz version: BetaRPi2
Location: Beitem, BE
Contact:

Re: Lag in Virtual Swtiches

Post by Egregius » Wednesday 11 January 2017 16:58

Maybe one day, who knows... I know it's there for at least one year now... Numerous topics have been created about it but no fix yet.
Anyway, once you have pass2php running you'll never think again of on/off actions ;)

User avatar
gizmocuz
Posts: 8491
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: Lag in Virtual Swtiches

Post by gizmocuz » Thursday 12 January 2017 10:44

Egregius wrote:Maybe one day, who knows... I know it's there for at least one year now... Numerous topics have been created about it but no fix yet.
It is by very accident that i am reading this topic, and seen this 'problem' for the first time...

Recently we have changed a lot of code to make it possible to minimize internal execution time...

Instead of working with scripts (we should try to 'keep it simple'), a quick look at the code would have revealed where the problem lies

specifically at the function:

bool CSQLHelper::HandleOnOffAction(const bool bIsOn, const std::string &OnAction, const std::string &OffAction)

In the next beta (#6334) i minimized the time from 1 second to 200ms, that should be sufficient.

Hope you guy's can test this to see if it's ok ?
Quality outlives Quantity!

matv
Posts: 22
Joined: Sunday 08 January 2017 19:26
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: EU
Contact:

Re: Lag in Virtual Swtiches

Post by matv » Saturday 14 January 2017 16:17

gizmocuz wrote:In the next beta (#6334) i minimized the time from 1 second to 200ms, that should be sufficient.
Hope you guy's can test this to see if it's ok ?
It's definitely better (running 3.6343 now).
If I understand you correctly the remainder of the lag (.3-.5 seconds now I estimate) is due to the line in the script that you quoted?
Do you think there is any way I can reduce it slightly more myself?

User avatar
gizmocuz
Posts: 8491
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: Lag in Virtual Swtiches

Post by gizmocuz » Sunday 15 January 2017 10:54

As said, 200ms is fast enough right ?
Quality outlives Quantity!

User avatar
Siewert308SW
Posts: 470
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Lag in Virtual Swtiches

Post by Siewert308SW » Sunday 15 January 2017 13:39

gizmocuz wrote:As said, 200ms is fast enough right ?
Couldn't find the cause but noticed that the speed increased.
Until i saw the commit it github.
Thx for decreasing the delay, it fast enough for me.
Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz / RFXtrx433E
1x RPi3 - PiHole / logging gas,elec
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/CoCo stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub
pico_status: @ GitHub

User avatar
Egregius
Posts: 2416
Joined: Thursday 09 April 2015 12:19
Target OS: Raspberry Pi
Domoticz version: BetaRPi2
Location: Beitem, BE
Contact:

Re: Lag in Virtual Swtiches

Post by Egregius » Sunday 15 January 2017 16:40

matv wrote:.3-.5 seconds now I estimate
How do you estimate that?
The logfile contains the only correct answer for that:

2017-01-15 15:39:43.514 (ZWAVE) Light/Switch (pirkeuken)
2017-01-15 15:39:43.534 User: Admin initiated a switch command (61/wasbak/On)
2017-01-15 15:39:43.534 OpenZWave: Domoticz has send a Switch command! NodeID: 6 (0x06)

User avatar
Siewert308SW
Posts: 470
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Lag in Virtual Swtiches

Post by Siewert308SW » Sunday 15 January 2017 16:50

Egregius wrote:
matv wrote:.3-.5 seconds now I estimate
How do you estimate that?
The logfile contains the only correct answer for that:

2017-01-15 15:39:43.514 (ZWAVE) Light/Switch (pirkeuken)
2017-01-15 15:39:43.534 User: Admin initiated a switch command (61/wasbak/On)
2017-01-15 15:39:43.534 OpenZWave: Domoticz has send a Switch command! NodeID: 6 (0x06)
2017-01-15 15:45:54.588 (RFXtrx433e) Lighting 2 (W.C Motion)
2017-01-15 15:45:54.590 (W.C Standby) Lighting 2 (W.C Standby)
2017-01-15 15:45:54.601 (RFXtrx433e) Lighting 2 (W.C Lamp)
Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz / RFXtrx433E
1x RPi3 - PiHole / logging gas,elec
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/CoCo stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub
pico_status: @ GitHub

matv
Posts: 22
Joined: Sunday 08 January 2017 19:26
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: EU
Contact:

Re: Lag in Virtual Swtiches

Post by matv » Sunday 15 January 2017 16:53

Thanks, you are right. I am new and was not aware of that option.
Below you will find the timestamps of my commands.

I do not want to use LUA scripts to speed up the process.
I guess the only thing I can do to gain some speed is removing all the scripts that I don't use in the script folder? Or does that not make a difference?

@gizmocuz thanks for the new beta's, the speed is workable now! :) (as opposed to the 1s delay mentioned earlier)

Code: Select all

2017-01-15 15:47:52.864 User: Admin initiated a switch command (6/Bureaulamp/Off)
2017-01-15 15:47:52.864 (Mi-Light-iBox) Lighting 1 (Bureaulamp)
2017-01-15 15:47:53.032 Executing script: /home/pi/domoticz/scripts/bwydoogh/milight-home.py
168 ms

Code: Select all

2017-01-15 15:47:54.007 User: Admin initiated a switch command (6/Bureaulamp/On)
2017-01-15 15:47:54.007 (Mi-Light-iBox) Lighting 1 (Bureaulamp)
2017-01-15 15:47:54.194 Executing script: /home/pi/domoticz/scripts/bwydoogh/milight-home.py
187 ms

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests