Page 1 of 1

Trigger dzvents script trough api.

Posted: Wednesday 04 March 2020 11:38
by OedzesG
Hallo,


at the moment im using Tautulli to monitor plex activitys, Tautulli can send an json call to domoticz based on playbacks.
i tested this with updating some uservariables and this works great..

But is there a way to trigger a dz.vents script by using a json call?

try to do something like this, but its not working..

Code: Select all

return {
	on = {
		devices = {
			'test'
		}
	},
	execute = function(domoticz, mySwitch)
			domoticz.emitEvent('my_switch').switchOn()
	
	end
}
and then i try to trigger it with:

Code: Select all

http://192.168.1.11:8080/json.htm?type=command&param=customevent&event=my_switch

Re: Trigger dzvents script trough api.

Posted: Wednesday 04 March 2020 13:44
by waaren
OedzesG wrote: Wednesday 04 March 2020 11:38 But is there a way to trigger a dz.vents script by using a json call?
try to do something like this, but its not working..
Syntax is a bit different

Code: Select all

-- CustomEvent trigger. !! Only  available in dzVents >= V3.0.0 !!
-- Triggered by JSON call <domoticz IP: domoticz port>/json.htm?type=command&param=customevent&event=myCustomEvent&data=myData

return 
{
    on = 
    {
        customEvents = 
        {
            'myCustomEvent',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when tested and OK
        marker = 'CustomEvent',
    },

    execute = function(dz, item)
        dz.log(item.trigger .. ' triggered this script ',dz.LOG_DEBUG)
        dz.log('payload is: '.. item.data,dz.LOG_DEBUG)
    end
}

Re: Trigger dzvents script trough api.  [Solved]

Posted: Wednesday 04 March 2020 17:26
by OedzesG
Syntax is a bit different
Thnx waaren! did the job!