Page 1 of 1

Disarm or Ignore Door Switch

Posted: Friday 10 November 2017 14:24
by Underdog85
Need some help trying to figure this out.

I have a bedside wireless switch which turns on/off the bedside lamps and a door sensor which automatically turns the lamps on when opened after sunset.

The issue: When I press the wireless on/off switch the lights go off but then when I open the door they turn back on.

Is there a way I can disarm the door sensor for 30 seconds and then re-arm the door allowing me to exit the room without them tuning back one?

Thanks

Re: Disarm or Ignore Door Switch

Posted: Friday 10 November 2017 14:52
by emme
sure...
you can use dzVents to work on lastUpdate value....

Code: Select all

return {
	on = {
		devices = {
			'myDoorDevice'
		}
	},
	execute = function(domoticz, device)
		local lampSwitch = domoticz.devices('myLampSwitch')
		local delay = 30 --delay in secs
		
		if device.lastUpdate.secondAgo > delay then
			lampSwitch.switchOn().checkFirst()
		end 
	end
}
by this... the door sensor will NOT switch on the light for the next n secs (based on the value set on delay)

Re: Disarm or Ignore Door Switch

Posted: Friday 10 November 2017 16:11
by Siewert308SW
Or in plain Lua.

Code: Select all


	function timedifference(s)
		year = string.sub(s, 1, 4)
		month = string.sub(s, 6, 7)
		day = string.sub(s, 9, 10)
		hour = string.sub(s, 12, 13)
		minutes = string.sub(s, 15, 16)
		seconds = string.sub(s, 18, 19)
		t1 = os.time()
		t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
		difference = os.difftime (t1, t2)
		return difference
	end

	if devicechanged["door_switch"] == 'Open'	
		and otherdevices["bedside_light"] == 'Off'
		and timedifference(otherdevices_lastupdate["light_switch"]) >= 30
	then	
		commandArray["bedside_light"]='On'	
	end


Re: Disarm or Ignore Door Switch

Posted: Saturday 11 November 2017 15:21
by Underdog85
Thanks both.

I don't have any experience with programming so the above doesn't make any sense to me. Is there a way you can break it down so I know where to insert my devices etc and how I go about this?