433MHz Window Contact dzVents scripting question.

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Cloudwraith
Posts: 6
Joined: Thursday 08 March 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

433MHz Window Contact dzVents scripting question.

Post by Cloudwraith »

Version: v3.9168
Platform: Pi 2b
Plugin/Hardware: dzVents
Description:
Based on this thread: http://www.domoticz.com/forum/viewtopic ... 28&t=19226

I purchased some 433MHz wireless contacts. I tried setting up the dzVents scripting as in that thread but so far I have not been able to trigger the dzVents system when either open signal is received. Since this sensor sends an open event when the magnet moves away and an open event when the magnet closes again, the intent was to set up both devices and control a virtual contact with scripting.

The log shows the RFLink is seeing the two devices properly however, the dzVents script never fires even if I set it to something simple like logging.

Code: Select all

2018-04-02 17:22:31.315 dzVents: Debug: • Device: Dining Room Temp/Humidity
2018-04-02 17:22:34.330 dzVents: Debug: Dumping domoticz data to /home/tallen/domoticz/scripts/dzVents/domoticzData.lua
2018-04-02 17:22:34.361 dzVents: Debug: Processing device-adapter for Bedroom 2 Temp/Humidity: Temperature+humidity device adapter
2018-04-02 17:22:34.361 dzVents: Debug: dzVents version: 2.4.2
2018-04-02 17:22:34.361 dzVents: Debug: Event triggers:
2018-04-02 17:22:34.361 dzVents: Debug: • Device: Bedroom 2 Temp/Humidity
2018-04-02 17:22:35.330 (RF_HUB) Light/Switch (W1Op)
2018-04-02 17:22:43.554 (RF_HUB) Light/Switch (W1Cl)
2018-04-02 17:22:58.902 dzVents: Debug: Dumping domoticz data to /home/tallen/domoticz/scripts/dzVents/domoticzData.lua
2018-04-02 17:22:58.945 dzVents: Debug: Processing device-adapter for Nanu Tank Temp: Temperature device adapter
2018-04-02 17:22:58.945 dzVents: Debug: dzVents version: 2.4.2
2018-04-02 17:22:58.945 dzVents: Debug: Event triggers:
Using the dzVents script editor in Events:

Code: Select all

return {
	on = {
		devices = {
			'W1Op'
		}
	},
	execute = function(domoticz, device)
          domoticz.log('Device ' .. device.name .. ' was activated', domoticz.LOG_INFO)
  	end
}
Here is the device in Switches: set up as a contact, light/switch, ev1527
Attachments
Device.jpg
Device.jpg (14.23 KiB) Viewed 664 times
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: 433MHz Window Contact dzVents scripting question.

Post by dannybloe »

Did you follow the troubleshooting section in the documentation? Are you sure your script is active (gui editor) or in the correct folder?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Cloudwraith
Posts: 6
Joined: Thursday 08 March 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: 433MHz Window Contact dzVents scripting question.

Post by Cloudwraith »

Yes. If I set the switch type to on/off and then virtually turn off the device by clicking on it, I can then set the device back to contact and when the open event happens the dzVents trigger fires. I just can't get the device to trigger an event on open, when it was last in an open state. I've tried device.active and device.changed but no joy.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: 433MHz Window Contact dzVents scripting question.

Post by dannybloe »

Yes, indeed.. I can reproduce that. That's a bug in Domoticz. It doesn't trigger the event system. The same happens for a Door Lock Inverted. I'll file a bug. For now you can change the device type to a Door Contact.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Cloudwraith
Posts: 6
Joined: Thursday 08 March 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: 433MHz Window Contact dzVents scripting question.

Post by Cloudwraith »

dannybloe wrote: Tuesday 03 April 2018 19:59 For now you can change the device type to a Door Contact.
Door contact doesn't appear to work either. On/Off does work, I haven't tried others other than contact and door contact but I can if it will help.
Cloudwraith
Posts: 6
Joined: Thursday 08 March 2018 21:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: 433MHz Window Contact dzVents scripting question.

Post by Cloudwraith »

Additionally, the dzVent script won't modify a contact type switch. It will modify a door contact.

Code: Select all

return {
	on = {
		devices = {
			'W1Cl'
		}
	},
	execute = function(domoticz, device)
			domoticz.devices('Front Room Window 1 (V)').close()
	end
}
Doesn't work if the virtual switch is a Contact but will work if it is a Door Contact
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: 433MHz Window Contact dzVents scripting question.

Post by dannybloe »

I did some more testing and created this script (after having created the switches as listed in the devices). When you press the vdTrigger switch in the GUI it should cause a chain of events: vdTrigger > vdDoorContact > vdDoorLock > vdDoorLockInverted > vdContact > vdTrigger

Which it doesn't. In my test only vdContact isn't triggered by vdDoorLockInverted. The rest does trigger.

(Oh, and yes, it doesn't seem to be possible to change the state of a Contact switch at all, no matter what state you send it. Certainly a Domoticz bug).

Code: Select all

return {
	active = true,
	on = {
		devices = {
			'vdTrigger',
			'vdContact',
			'vdDoorContact',
			'vdDoorLock',
			'vdDoorLockInverted'
		},
	},
	data = {
		varContact = {initial = false},
		varDoorContact = {initial = false},
		varDoorLockInverted = {initial = false},
		varDoorLock = {initial = false}
	},
	execute = function(dz, item)

		-- vdTrigger > vdDoorContact > vdDoorLock > vdDoorLockInverted > vdContact > vdTrigger

		if (item.name == 'vdDoorContact') then
			dz.data.varDoorContact = true
			dz.devices('vdDoorLock').switchOn() -- activate > locked
		end

		if (item.name == 'vdDoorLock') then
			dz.data.varDoorLock = true
			dz.devices('vdDoorLockInverted').switchOff()  -- inverted > de-activate > locked
		end

		if (item.name == 'vdDoorLockInverted') then
			dz.data.varDoorLockInverted = true
			dz.devices('vdContact').open()
		end

		if (item.name == 'vdContact') then
			dz.data.varContact = true
			dz.devices('vdTrigger').switchOff()
		end

		if (item.name == 'vdTrigger') then
			if (item.active) then
				dz.devices('vdDoorContact').open()
			else
				if (dz.data.varContact and dz.data.varDoorContact and dz.data.varDoorLockInverted) then
					item.switchOff().silent() -- means success
				else
					item.switchOn().silent() -- fail, at the end this should be On
				end
			end
		end

		dz.utils._.print(dz.data)
	end
}

Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest