Page 1 of 1

Lights on/Off Blockly Issue

Posted: Friday 22 June 2018 8:07
by alarm_guy1
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

Re: Lights on/Off Blockly Issue

Posted: Friday 22 June 2018 8:21
by snellejellep
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
}

Re: Lights on/Off Blockly Issue

Posted: Friday 22 June 2018 13:04
by alarm_guy1
Thankyou ill give it a bash...