Script delay

Moderator: leecollings

daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Script delay

Post by daveinhull »

HI,

Just a quick question (I hope).

I have a LUA script which detects a LightwaveRF mood switch button and turns on a light. It takes between 2 to 3 seconds for this to happen when the button is pressed.

Is this the expected duration to process a simple script, or should it be quicker?

Thanks
Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
User avatar
gizmocuz
Posts: 2484
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Script delay

Post by gizmocuz »

we might want to see your script ;)
Quality outlives Quantity!
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Yes of course ;)

Code: Select all

function getdifference(device)
	t1 = (os.time())
	s = otherdevices_lastupdate[device]
	year = string.sub(s, 1, 4)
	month = string.sub(s, 6, 7)
	day = string.sub(s, 9, 10)
	hour = string.sub(s, 12, 13)
	minutes = string.sub(s, 15, 16)
	seconds = string.sub(s, 18, 19)
	t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
	return os.difftime (t1, t2)
end

commandArray = {}
c=next(devicechanged)
v=tostring(devicechanged[c])
print '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
print ('Mood => Trigger device -> '..c..' with data "'..v..'"')
if(c == 'Main Bedroom Mood') then
	if(v == 'Group Mood 1') then
		difference = getdifference('Main Bedroom Bedhead 1')
		if (tostring(otherdevices['Main Bedroom Bedhead 1'])=='Off') then
			commandArray['Main Bedroom Bedhead 1'] = 'Set Level 10'
		elseif (tostring(otherdevices['Main Bedroom Bedhead 1'])=='Set Level') and difference < 5 then
			commandArray['Main Bedroom Bedhead 1'] = 'Set Level 100'
		elseif difference > 5 then
			commandArray['Main Bedroom Bedhead 1'] = 'Off'
		end
	elseif(v == 'Group Mood 2') then
		difference = getdifference('Main Bedroom Bedhead 2')
		if (tostring(otherdevices['Main Bedroom Bedhead 2'])=='Off') then
			commandArray['Main Bedroom Bedhead 2'] = 'Set Level 10'
		elseif (tostring(otherdevices['Main Bedroom Bedhead 2'])=='Set Level') and difference < 5 then
			commandArray['Main Bedroom Bedhead 2'] = 'Set Level 100'
		elseif difference > 5 then
			commandArray['Main Bedroom Bedhead 2'] = 'Off'
		end
	elseif(v == 'Group Mood 3') then
		difference = getdifference('Main Bedroom Ceiling')
		if (tostring(otherdevices['Main Bedroom Ceiling'])=='Off') then
			commandArray['Main Bedroom Ceiling'] = 'Set Level 10'
		elseif (tostring(otherdevices['Main Bedroom Ceiling'])=='Set Level') and difference < 5 then
			commandArray['Main Bedroom Ceiling'] = 'Set Level 100'
		elseif difference > 5 then
			commandArray['Main Bedroom Ceiling'] = 'Off'
		end
	elseif(v == 'Group Mood 4') then
	elseif(v == 'Group Mood 5') then
	elseif(v == 'Group Off') then
		commandArray['Main Bedroom Bedhead 1'] = 'Off'
		commandArray['Main Bedroom Bedhead 2'] = 'Off'
		commandArray['Main Bedroom Ceiling'] = 'Off'
	else
		print('Unknown value'..v)
	end
end
print '-----------------------------------------------------------'
return commandArray
Thoughts?

Thanks
Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
User avatar
gizmocuz
Posts: 2484
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Script delay

Post by gizmocuz »

i cant see a problem / delay in the script, if you press one button, do you directly see a log line that it is received?
Quality outlives Quantity!
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi,

Not always, sometimes it appears immediately and other times it can take a few seconds.

Thanks
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi,

Any thoughts anyone?

Thanks
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

HI,

I've just checked with RFXmngr and the switch signals are received almost immediately, but in Domoticz they can take 5 or 6 seconds to appear in the log (although I appreciate that there may well be a time delay in updating the log).

Irrespective of the log, it does take around 2 second for the Domoticz to detect the switch signal in a LUA script and issue the light on signal - can any say if this is the expected time?

Any help would be appreciated, even if it is just to say that the delay is expected.

Thanks
Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
User avatar
gizmocuz
Posts: 2484
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Script delay

Post by gizmocuz »

besides the lua/scripting, the display web gui updates every 10 seconds
Quality outlives Quantity!
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Script delay

Post by simonrg »

daveinhull wrote:HI,

I've just checked with RFXmngr and the switch signals are received almost immediately, but in Domoticz they can take 5 or 6 seconds to appear in the log (although I appreciate that there may well be a time delay in updating the log).

Irrespective of the log, it does take around 2 second for the Domoticz to detect the switch signal in a LUA script and issue the light on signal - can any say if this is the expected time?

Any help would be appreciated, even if it is just to say that the delay is expected.

Thanks
Dave
2 seconds would seem reasonable, 5 to 6 would seem a bit long, do you have other scripts?

Calling this script script_device_asomething.lua - does this speed it up?
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi,

Thanks for the reply. There were no other 'legally named' scripts in the lua directory, but I've moved everything out and its still about 2 to 3 seconds to go through button press light on.
Not sure what you mean
Calling this script script_device_asomething.lua - does this speed it up?
but it was called script_device_DavesMood.lua, so I renamed it as suggested - no change, still around 2 to 3 seconds.

I also disabled all the Blockly scripts, not many, but just making sure there was nothing else that could be doing things - still no change.

As I mentioned RFXmgnr sees the button press almost immediately, so I'm not sure why there is a 2 to 3 second delay.

Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Script delay

Post by ThinkPad »

I see you are running Domoticz on Windows.
Maybe Windows adds to much overhead, which causes Domoticz to work slower?

Try running Domoticz in a linux virtual machine or on a Raspberry Pi, see if it works faster there (more bare metal OS == less overhead).
I am not active on this forum anymore.
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi ThinkPad,

Yes that is were my thoughts were heading to also, but....

I did a little more testing and found that the log shows that when the switch signal is received the script is run and the light-on signal sent all within, a decent, 1/2 second.

So the delay must be in Domoticz detecting the switch signal. However...
  • RFXmgnr (on the same windows machine) detects the signal almost immediately - so can't really be the Windows PC.
  • Also the Windows PC is a Shuttle(XS36V) with an Atom [email protected] process running nothing else but Domoticz (other than the usual Windows stuff of course), so again surprised that its the PC
I also setup a scene which switched the same light on from the same switch (and disabled the script) and the timing is slight, but noticeably, faster, maybe a half second or so - but still no way as quick as either a direct pairing between the switch and the light (both LightwaveRF) or course, or the RFXmgnr.

So conclusion so far is that Domoticz is not seeing the switch signal as fast as RFXmgnr is seeing it. One difference of course is that Domoticz is running as a service whereas RFXmgnr is not, but I wouldn't expect that to cause such a delay, or would it? What are the factors involved in a signal being received by the RFXcom driver and Domoticz being notified?

Thoughts?

Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Script delay

Post by StanHD »

Hi, If it's any help, I am using Z-Wave PIRs and LightwaveRF Remote switches to operate LightwaveRF dimmer switches and relays. Domoticz running as a service on Windows 7 on a Celeron NUC.(Dedicated).

Usually I do not experience any noticeable delays. Rarely there is a 2-3 second delay, but I assume that is when my Evohome or 1-Wire is coincidentally updating at the same moment. Otherwise things are pretty much "instant".
I don't use scripts just Blockly, and some of the lighting ones are checking states of several other devices before execution.

Happy to "test" something with my setup if it helps?
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi StanHD,

Thanks for the feedback and offer to help.... :D :D

Do you have a LightwaveRF mood switch? If you do maybe you could put the following Lua script into the Domoticz/Scripts/Lua directory and then test it and see how long it takes.

You'd need to setup the mood switch as an on/off generic switch called Mood1 (or something, so long as the script name is the same) and have a light that you can turn on called Light1 (or again something that is the same in the script).

Code: Select all

commandArray = {}
c=next(devicechanged)
v=tostring(devicechanged[c])
if(c == 'Mood1') then
	if(v == 'Group Mood 1') then
		commandArray['Light1'] = 'On'
        else
		commandArray['Light1'] = 'Off'
	end
end
return commandArray
Probably best if the mood switch is not involved I anything else.
Then when you press button 1 (the one with one dot on it) it should turn the light on, any other button should turn it off.

If you could check the performance and also have a look in the Domoticz log to see the timings that would be great. The log will only show you the times when Domotiz see's the switch signal, so from actually pressing the button to the light coming on will have to be just visible timings. As I said in a previous post, the Domoticz log shows that it processes the signal with 1/2 a second, but the user experience is much slower. I guess without some expensive 433mhz monitoring equipment I can see what happens between the switch and the RFXcom receiver, although RFXmgnr does see it a lot quicker than Domoticz.

Many thanks in advance, at least I can see if it my Shuttle that is slowing things down.

Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
iMiMx
Posts: 9
Joined: Wednesday 21 January 2015 18:38
Target OS: Linux
Domoticz version:

Re: Script delay

Post by iMiMx »

Hi there,

I see something similar, however I put it down to the 'slow-start' on the LED lights - I think this is supposedly to improve their life? What lights/housing are you using? I see 2-3 second delay with my GU10 Megaman downlights, with LightwaveRF dimmers, however the Hue lights called from the same Scene action on the Mood switch turn on visibly before the downlights (although there is obviously no lightwaverf action for turning the lights on here). My scripts do check a few things first, time of day, is it dark, brightness in the room (Z-wave motion sensors) etc and then act accordingly.

It does take probably 0.5 seconds or so for the lights turn on even when using their own physical switch. I have 10 mood switches around the house, downlights are always slightly slower than the Hue lights. Using an Ubuntu VM running on vSphere cluster.

UPDATE: I was just in the process of finishing off my iRule remote (iOS), this calls the JSON urls and the lights respond almost immediately (as fast as they do when using their physical switch). Using the Mood switch it is still the 2-3 seconds, usually the lower end, so potentially something with receiving/sending the commands with RFX (is there a 'sleep' or anything between commands?) or script processing.

Cheers,
Last edited by iMiMx on Wednesday 26 August 2015 17:22, edited 1 time in total.
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Script delay

Post by StanHD »

Hi Dave,

I don't have a mood switch, but tonight I can try to test the script with a lwrf wireless switch (JSJS LW221). Would that be comparable?

Stan
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi Stan,

Yes I guess it would, but you'd probably need to change the script to something like:

Code: Select all

commandArray = {}
c=next(devicechanged)
v=tostring(devicechanged[c])
if(c == 'Switch') then
	if(v == 'On') then
		commandArray['Light1'] = 'On'
	else
		commandArray['Light1'] = 'Off'
	end
end
return commandArray
Although I'm not sure what the data would be with the switch, I'm assuming On/Off - I'll dig out a wireless switch and test it.

Many thanks

Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi Stan,

Did you manage to get chance to test the wireless switch with script? Any results?

Thanks
Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
User avatar
StanHD
Posts: 347
Joined: Friday 12 July 2013 16:09
Target OS: Windows
Domoticz version:
Location: East Sussex, UK
Contact:

Re: Script delay

Post by StanHD »

Hi Dave,

Really sorry for the delay, got called away for work, then away for weekend.

Anyway, have tested using a LWRF remote control and also a wireless switch, both with a LWRF Dimmer and then a LWRF relay (on/off).
With the dimmer, the reaction was @ 0.5 - 1 second (max).
With the On/Off relay, the reaction was instant.

I think the dimmer reaction was dampened by the "soft start" effect that is built into it.

For background, I am running Version 2.2873 on a Celeron NUC. I have 30 Blockly Scripts and 129 Devices. No other Lua Scripts though.

Stan
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
daveinhull
Posts: 22
Joined: Thursday 20 August 2015 11:30
Target OS: Windows
Domoticz version: V2.2657
Location: UK
Contact:

Re: Script delay

Post by daveinhull »

Hi Stan,

Many thanks for testing this and absolutely need to apologies. So it sounds like something in my system is slowing things down, but where?

I need to break the system down into components and test each bit....that'll keep be occupied for a bit :(

I'm running version 2.2657, so will upgrade to the latest.

Thanks again

Dave
Domoticz running on Windows 10 x64 Shuttle PC
RFComm, 9wall dimmers, 4dual sockets, 3x3way relays, 1x1way relay, 4PIRs, 2magnetic switches, 1radiator valve, WiFi link, coiler switch and controller, compatible security system, & lots of patience
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest