Trigger dzvents script trough api.  [Solved]

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

Moderator: leecollings

Post Reply
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Trigger dzvents script trough api.

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Trigger dzvents script trough api.

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
OedzesG
Posts: 106
Joined: Monday 11 March 2019 0:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Trigger dzvents script trough api.  [Solved]

Post by OedzesG »

Syntax is a bit different
Thnx waaren! did the job!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest