Blocky to LUA

Moderator: leecollings

Post Reply
Deva
Posts: 3
Joined: Thursday 17 September 2015 11:57
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Blocky to LUA

Post 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.
Attachments
blocky.JPG
blocky.JPG (88.27 KiB) Viewed 2835 times
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Blocky to LUA

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

Re: Blocky to LUA

Post 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
elmortero
Posts: 247
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: Blocky to LUA

Post 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
 }
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest