Page 1 of 1

Bug triggering device [SOLVED]

Posted: Sunday 05 June 2022 21:09
by acaonweb
I've wrote a simple dz script, triggering a single device

Code: Select all

return {
	on = {
		devices = {'Irrigatore'},
		timer = {},
		variables = {},
		scenes = {},
		groups = {},
		security = {},
		httpResponses = {},
		shellCommandResponses = {},
		customEvents = {},
		system = {},
	},
	data = {},
	logging = {level = domoticz.LOG_DEBUG, marker = "BugTest: "},
	execute = function(dz, device, triggeredItem)
	    if(triggeredItem.type == dz.EVENT_TYPE_DEVICE) then
	        dz.log("triggering it")
	        dz.notify('Test', device.state, dz.PRIORITY_NORMAL,0,'iPhone6S',dz.NSS_PUSHOVER)
        end
        

	end
}
If I change state of irrigatore device, I expect a push notification, but I have twice notification.
The log says:

Code: Select all

2022-06-05 21:01:33.208 Status: dzVents: Info: BugTest: : ------ Start internal script: Script #2: Device: "Irrigatore (Dummy)", Index: 116
2022-06-05 21:01:33.209 Status: dzVents: Info: BugTest: : triggering it
2022-06-05 21:01:33.210 Status: dzVents: Info: BugTest: : ------ Finished Script #2
2022-06-05 21:01:33.395 Status: dzVents: Info: BugTest: : ------ Start internal script: Script #2: Device: "Irrigatore (Dummy)", Index: 116
2022-06-05 21:01:33.396 Status: dzVents: Info: BugTest: : triggering it
2022-06-05 21:01:33.397 Status: dzVents: Info: BugTest: : ------ Finished Script #2
and the push notification are two, like the screenshot shows:
IMG_3499.jpg
IMG_3499.jpg (245.91 KiB) Viewed 1121 times
I think is a bug, or a big mistake in the script.

My setup:

Code: Select all

Version: 2022.1 (build 14352)
Build Hash: 5765540b9
Compile Date: 2022-06-03 07:39:12
dzVents Version: 3.1.8
Python Version: 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs

Re: Bug triggering device

Posted: Monday 06 June 2022 15:47
by waltervl
What kind of device is that Irrigatore device? How do you trigger it? It could be that it is triggered twice eg On and Off. You could add a device state to the logging to see what triggered the second run.

Re: Bug triggering device

Posted: Monday 06 June 2022 17:00
by acaonweb
it's a dummy and i trigger it from dashboard, clicking on it
i'll add a device.state to the log

Re: Bug triggering device

Posted: Monday 06 June 2022 17:15
by acaonweb
i've added device.state to the log, clicking once the dummy device initial state off, i have that

Code: Select all

2022-06-06 17:08:58.779 Status: dzVents: Info: BugTest: : ------ Start internal script: Script #2: Device: "Irrigatore (Dummy)", Index: 116
2022-06-06 17:08:58.806 Status: dzVents: Info: BugTest: : triggering it
2022-06-06 17:08:58.807 Status: dzVents: Info: BugTest: : state: On
2022-06-06 17:08:58.809 Status: dzVents: Info: BugTest: : ------ Finished Script #2
2022-06-06 17:08:58.981 Status: dzVents: Info: BugTest: : ------ Start internal script: Script #2: Device: "Irrigatore (Dummy)", Index: 116
2022-06-06 17:08:58.982 Status: dzVents: Info: BugTest: : triggering it
2022-06-06 17:08:58.982 Status: dzVents: Info: BugTest: : state: On
2022-06-06 17:08:58.983 Status: dzVents: Info: BugTest: : ------ Finished Script #2

Re: Bug triggering device

Posted: Monday 06 June 2022 20:12
by madpatrick
Maybe this can be something

Code: Select all

 triggeredItem
Try to change

Code: Select all

 execute = function(dz, device, triggeredItem)
Into

Code: Select all

 execute = function(dz, device)

Re: Bug triggering device

Posted: Monday 06 June 2022 21:09
by acaonweb
Well, I need triggeredItem because I’m the original script I need to trigger a device and do some actions) and a timer (and do other action)

Re: Bug triggering device

Posted: Monday 06 June 2022 22:02
by plugge
acaonweb wrote: Monday 06 June 2022 21:09 Well, I need triggeredItem because I’m the original script I need to trigger a device and do some actions) and a timer (and do other action)
You don't need it anymore since version 2.4.0.
From the manual:
3. (domoticz, item, triggerInfo)
Note: as of version 2.4.0, triggerInfo has become more or less obsolete and is left in here for backward compatibility. All information is now available on the item parameter (second parameter of the execute function, see point 2 above).
You could try without the 'triggerInfo' parameter and see if that removes the double trigger.

See what happens if you change:

Code: Select all

if(triggeredItem.type == dz.EVENT_TYPE_DEVICE) then
into

Code: Select all

if device.isDevice then