Lights on/Off Blockly Issue

Post Reply
alarm_guy1
Posts: 19
Joined: Tuesday 14 January 2014 1:03
Target OS: Linux
Domoticz version:
Contact:

Lights on/Off Blockly Issue

Post by alarm_guy1 » Friday 22 June 2018 8:07

Hi
I have a Blockly that says if my Kitchen sensor s active and the lux is less than 30 then turn on kitchen light for 10mins.

WORKS A TREAT

However if someone turns the light switch off as they leave the kitchen whilst the light is on within to 10 min period, the light goes off as expected.
However once the 10mins has elapsed the light then turns back on, again I can see why as it is only sending a change of state.

the relay is a Fibaro FGS-223

can I control this in Blockly?

many thanks
Attachments
Blockly.jpg
Blockly.jpg (29.66 KiB) Viewed 189 times

snellejellep
Posts: 105
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi
Domoticz version: 3.97xx
Location: The Neterlands
Contact:

Re: Lights on/Off Blockly Issue

Post by snellejellep » Friday 22 June 2018 8:21

a dzvents script like this should do:

Code: Select all

return {
	on = {
		devices = {
			"Kitchen Sensor Burglar",
		    "Kitchen Lights"
		}
	},
	execute = function(dz, device)
	
	    local Sensor        = dz.devices("Kitchen Sensor Burglar")
	    local Lux           = dz.devices("Kitchen Sensor Lux").lux
    	local Lights        = dz.devices ("Kitchen Lights")
	
    	if (Sensor.state == "On")  and (Lights.state == "Off")  and Lux < 30 then
	        Lights.switchOn()
    	elseif (Lights.state == "On")  and Sensor.lastUpdate.minutesAgo > 10 then
	        Lights.switchOff()
    	end
	
	end
}
raspberry pi | xiaomi gateway/vacuum | yeelight | philips hue | zwave |ubiquiti unifi | harmony

alarm_guy1
Posts: 19
Joined: Tuesday 14 January 2014 1:03
Target OS: Linux
Domoticz version:
Contact:

Re: Lights on/Off Blockly Issue

Post by alarm_guy1 » Friday 22 June 2018 13:04

Thankyou ill give it a bash...

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests