Disarm or Ignore Door Switch

Post Reply
Underdog85
Posts: 2
Joined: Friday 10 November 2017 15:17
Target OS: Raspberry Pi
Domoticz version:
Contact:

Disarm or Ignore Door Switch

Post by Underdog85 » Friday 10 November 2017 15:24

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

User avatar
emme
Posts: 644
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Disarm or Ignore Door Switch

Post by emme » Friday 10 November 2017 15:52

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)
That's one small step for a programmer, one giant leap for me!
- - - - -
Raspberry Pi3 + AeonStick G5 + RFXCOMM433 + iRTrans Server + NodeJS
There's no stress in the mess!!

User avatar
Siewert308SW
Posts: 499
Joined: Monday 29 December 2014 16:47
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands - Zoutkamp (gn)
Contact:

Re: Disarm or Ignore Door Switch

Post by Siewert308SW » Friday 10 November 2017 17:11

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

Setup:
1x RPi3 - PIco hv3.0A Plus / Domoticz
1x RPi3 - PIco hv3.0A Plus / PiHole
1x RFXtrx433E / Aeotec ZW090
3x FI9803P Cam
2x Youless Elec/Gas
4x KD101 detectors
a lot of KaKu/z-wave stuff

Domoticz scripts: @ GitHub
pico_installer: @ GitHub

Underdog85
Posts: 2
Joined: Friday 10 November 2017 15:17
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Disarm or Ignore Door Switch

Post by Underdog85 » Saturday 11 November 2017 16:21

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?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests