Page 1 of 1

triggerInfo.trigger for device change?

Posted: Wednesday 17 January 2018 13:19
by anasazi
Hi,

According to the dzVents wiki, triggerInfo.trigger only works for timer rules and for security state.
Is it possible to use this when devices changes also?

Check the example script below, is this possible?

Code: Select all

return {

	active = true,

	on = {
		security = {
			domoticz.SECURITY_ARMEDAWAY,
			domoticz.SECURITY_DISARMED,
		},
		devices = {
			'$Alarm - Detekterat',
		},

	},

	execute = function(domoticz, device, triggerInfo)

		if (triggerInfo.trigger == domoticz.SECURITY_ARMEDAWAY) then
			domoticz.devices('$Alarm - Delay Active').switchOn().forMin(1)
            		domoticz.devices('Siren').switchOn().forSec(1)
				
		elseif (triggerInfo.trigger == domoticz.SECURITY_DISARMED) then
			domoticz.devices('$Alarm - Siren Trigger').switchOff()
			domoticz.devices('$Alarm - Detekterat').switchOff()
			domoticz.devices('Siren').switchOff()
			domoticz.devices('$Alarm - Delay Active').switchOff()
			
		elseif (triggerInfo.trigger == '$Alarm - Detekterat') then
			if (device.state == 'On') then
				domoticz.devices('$Alarm - Siren Trigger').switchOn().afterSec(30)
				domoticz.devices('Siren').switchOn().forSec(1)
			end
        end
	end
}

Re: triggerInfo.trigger for device change?

Posted: Wednesday 17 January 2018 13:57
by emme
Use device.name

Re: triggerInfo.trigger for device change?

Posted: Wednesday 17 January 2018 18:39
by SweetPants
anasazi wrote: Wednesday 17 January 2018 13:19 Hi,

According to the dzVents wiki, triggerInfo.trigger only works for timer rules and for security state.
Is it possible to use this when devices changes also?

Check the example script below, is this possible?

Code: Select all

return {

	active = true,

	on = {
		security = {
			domoticz.SECURITY_ARMEDAWAY,
			domoticz.SECURITY_DISARMED,
		},
		devices = {
			'$Alarm - Detekterat',
		},

	},

	execute = function(domoticz, device, triggerInfo)

		if (triggerInfo.trigger == domoticz.SECURITY_ARMEDAWAY) then
			domoticz.devices('$Alarm - Delay Active').switchOn().forMin(1)
            		domoticz.devices('Siren').switchOn().forSec(1)
				
		elseif (triggerInfo.trigger == domoticz.SECURITY_DISARMED) then
			domoticz.devices('$Alarm - Siren Trigger').switchOff()
			domoticz.devices('$Alarm - Detekterat').switchOff()
			domoticz.devices('Siren').switchOff()
			domoticz.devices('$Alarm - Delay Active').switchOff()
			
		elseif (triggerInfo.trigger == '$Alarm - Detekterat') then
			if (device.state == 'On') then
				domoticz.devices('$Alarm - Siren Trigger').switchOn().afterSec(30)
				domoticz.devices('Siren').switchOn().forSec(1)
			end
        end
	end
}
I'm using if (triggerinfo.type == domoticz.EVENT_TYPE_DEVICE) then with dzVentz 2.3.0

Re: triggerInfo.trigger for device change?

Posted: Thursday 18 January 2018 7:50
by anasazi
emme wrote: Wednesday 17 January 2018 13:57Use device.name
Hi,

I have tried with device.name in combination with infoTrigger.info and it's woking, thanks!
Then I tried to add more devices and I added a wild-card device but this won't work when using device.name, see the example script below what I mean...

is this supposed to work or am I writing the script wrong?

Code: Select all

return {

	active = true,

	on = {
		security = {
			domoticz.SECURITY_ARMEDAWAY,
			domoticz.SECURITY_DISARMED,
		},
		devices = {
			'*dörren',
		},

	},

	execute = function(domoticz, device, triggerInfo)

		if (triggerInfo.trigger == domoticz.SECURITY_ARMEDAWAY) then
			domoticz.devices('$Alarm - Delay Active').switchOn().forMin(1)
            		domoticz.devices('Siren').switchOn().forSec(1)
			
		elseif (triggerInfo.trigger == domoticz.SECURITY_DISARMED) then
			domoticz.devices('$Alarm - Siren Trigger').switchOff()
			domoticz.devices('$Alarm - Detekterat').switchOff()
		    	domoticz.devices('Siren').switchOff()
		    	domoticz.devices('$Alarm - Delay Active').switchOff()
			
		elseif (device.name == '*dörren') then
			if (device.state == 'On') then
				domoticz.devices('$Alarm - Siren Trigger').switchOn().afterSec(30)
				domoticz.devices('Siren').switchOn().forSec(1)
			end
        end
	end
}

Re: triggerInfo.trigger for device change?

Posted: Thursday 18 January 2018 8:51
by dannybloe
Looks good to me, give it a try.. hire some burglars perhaps to help...

Re: triggerInfo.trigger for device change?

Posted: Thursday 18 January 2018 20:10
by waaren
Can you change

Code: Select all

elseif (device.name == '*dörren') then
into

Code: Select all

elseif string.find(device.name,'dörren') ~= nil then
and report back what the result is ?

Re: triggerInfo.trigger for device change?

Posted: Friday 19 January 2018 10:06
by anasazi
Hi,

I will try with your recommendations this weekend.
Thanks!