Page 1 of 1

Blocky to LUA

Posted: Friday 09 December 2016 10:02
by Deva
Hi all,

First of all, let me start with thanking you all for the good work what has been done! I've used so many tips, thank you.

Now I need a LUA guru, because I am a LUA programmer n00b. :roll:

Because of the time delay (blocky response is slow, up to 3/6 seconds). I want to test if a LUA solution is faster. Having no knowledge about LUA, I'm kinda stuck here.

Is someone willing to help me out?

Purpose of this blocky:

I have a fibaro motion sensor and a KAKU door contact (sensor 354).

When opening the door OR motion is detected AND lux is below or equal to 15, the light is turned on. There is a dummy switch with a 3 minute OFF delay. Everytime motion is detected, the countdown timer is reset.

Re: Blocky to LUA

Posted: Friday 09 December 2016 11:49
by Nautilus
gizmocuz wrote:You can place the swithes in a room, there you will see the hidden switches if you need
I understand you want some sort of 'toggle' mode, yes this is possible with a blockly too, no need for a lua script as blockly is faster
viewtopic.php?f=24&t=10105&p=106800&hil ... er#p106800

Re: Blocky to LUA

Posted: Friday 09 December 2016 11:56
by Egregius
Are you sure it's the blockly that causes the delay?
Have you looked at the time stamps of pir and switch command in the logfile?
If you know PHP you can also use that for this: http://www.domoticz.com/forum/viewtopic ... 23&t=12343
I only have 42msec between pir and switch time :D

Re: Blocky to LUA

Posted: Thursday 15 December 2016 15:00
by elmortero
I don't know if this will speed up things, but it answers your question I think.
This Lua script should do the same as your blockly.
This one needs dzvents to work. It is worth installing it as it makes lua scripting a lot easier.
The dummy switch is not needed for this script as the for_min(3) will switch the light on and turn it off after 3 minutes

https://github.com/dannybloe/dzVents

Code: Select all

return {
	active = true,
	on = {
	'Sensor-Schuur',
	'354'
	},

     execute = function(domoticz)
     local sensor = domoticz.devices['Sensor-Schuur']
     local door = domoticz.devices['354']
	 local lumi = domoticz.devices['LUX-Garage']
	 local lamp = domoticz.devices['Lamp-Binnenspot Schuur']
	 
		if ((sensor.state == 'On' or door.state == 'Open') and (lumi.lux < 16))
			and (lamp.state == 'Off')
		then lamp.switchOn().for_min(3)
		end
 end
 }