Lights on/Off Blockly Issue

Moderator: leecollings

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

Lights on/Off Blockly Issue

Post 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
Attachments
Blockly.jpg
Blockly.jpg (29.66 KiB) Viewed 1063 times
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Lights on/Off Blockly Issue

Post 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
}
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
alarm_guy1
Posts: 132
Joined: Tuesday 14 January 2014 0:03
Target OS: Linux
Domoticz version:
Contact:

Re: Lights on/Off Blockly Issue

Post by alarm_guy1 »

Thankyou ill give it a bash...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest