Plugin SDK- event example?

Posted on
Sun Apr 22, 2018 5:05 pm
brettlid offline
Posts: 27
Joined: Nov 28, 2017

Plugin SDK- event example?

I'm trying to understand the mechanism to be able to handle events in my plugin. I downloaded the SDK but there doesn't seem to be any examples. Am I missing something? Some simple example would really help.

Thanks

Posted on
Sun Apr 22, 2018 5:12 pm
kw123 offline
User avatar
Posts: 6009
Joined: May 12, 2013
Location: Dallas, TX

Re: Plugin SDK- event example?

Do you want to handle events created outside the plugin or create events within the plugin?

The second Is done with triggers in the plugin.


Sent from my iPhone using Tapatalk

Posted on
Sun Apr 22, 2018 6:13 pm
matt (support) offline
Site Admin
User avatar
Posts: 18735
Joined: Jan 27, 2003
Location: Texas

Re: Plugin SDK- event example?

Yes, as Karl said give us some more details about what you are trying to do and we can get you pointed in the right direction.

Image

Posted on
Sun Apr 22, 2018 6:54 pm
brettlid offline
Posts: 27
Joined: Nov 28, 2017

Re: Plugin SDK- event example?

Both would be great, but more specifically in response to z-wave notifications the plug in receives. I just don't see any examples of either events in the SDK examples.

Thanks

Posted on
Sun Apr 22, 2018 7:16 pm
Colorado4Wheeler offline
User avatar
Posts: 2749
Joined: Jul 20, 2009
Location: Colorado

Re: Plugin SDK- event example?

Take a look at the Plugin Examples folder in your Indigo installation, there are lots of examples there of varying types that you can refer to.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Apr 22, 2018 7:49 pm
matt (support) offline
Site Admin
User avatar
Posts: 18735
Joined: Jan 27, 2003
Location: Texas

Re: Plugin SDK- event example?

Download and install all the Indigo SDK Examples discussed here (there is a link in the first post).

There is one specifically for catching lower-level Z-Wave packets.

Image

Posted on
Sun Apr 22, 2018 9:50 pm
kw123 offline
User avatar
Posts: 6009
Joined: May 12, 2013
Location: Dallas, TX

Re: Plugin SDK- event example?

the thing with events / riggers is a bit confusing but logical:

A device can create an event OR a plugin can
Then in indigo menu you create a Trigger that listens to events

In the plugin you need to define an event in events.xml :
Code: Select all
</Events>
    <Event id="xxxxxaaaaa"><Name>your text for the menu</Name> </Event>
</Events>

and something like this in your code
Code: Select all
     def triggerStartProcessing(self, trigger):
        self.triggerList.append(trigger.id)
     def triggerStopProcessing(self, trigger):
        if trigger.id in self.triggerList:
            self.triggerList.remove(trigger.id)

     def triggerEvent(self, eventId):
        for trigId in self.triggerList:
            trigger = indigo.triggers[trigId]
            if trigger.pluginTypeId == eventId:
                indigo.trigger.execute(trigger)
        return
And you trigger it in your plugin with:
Code: Select all
self.triggerEvent(u"xxxxxaaaaa")
then the trigger you defined in indigo will be triggered by the event created by the plugin

so:
Plugin defines events and creates an event with a method indigo.triggerexecute(trigger) That event then triggers the indigo trigger you defined in the indigo menu..
It took me some time to understand trigger in the plugin vs trigger in the indigo menu.

very rough overview from my perspective..

Karl
ps you need to initialize
self.triggerList =[]
somewhere in startup()

Posted on
Mon Apr 23, 2018 12:00 am
howartp offline
Posts: 3349
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Plugin SDK- event example?

Also feel free to browse my plugins on here; all the Zwave * Plugins trigger on incoming Zwave values.


Sent from my iPhone using Tapatalk Pro

Posted on
Mon Apr 23, 2018 9:30 am
brettlid offline
Posts: 27
Joined: Nov 28, 2017

Re: Plugin SDK- event example?

Thanks to everyone who responded. I'll look thru the SDK examples again, but I didn't see one that included the EVENTS.XML file.

Thanks

Posted on
Mon Apr 23, 2018 8:29 pm
howartp offline
Posts: 3349
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Plugin SDK- event example?

brettlid wrote:
Thanks to everyone who responded. I'll look thru the SDK examples again, but I didn't see one that included the EVENTS.XML file.

Thanks

You won’t cos there isn’t one. :-)

I presume you’ve seen the docs at http://wiki.indigodomo.com/doku.php?id= ... in_guide&s[]=triggerstartprocessing#eventsxml


Sent from my iPhone using Tapatalk Pro

Posted on
Tue Apr 24, 2018 10:34 am
jay (support) offline
Site Admin
User avatar
Posts: 14887
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Plugin SDK- event example?

If your plugin defines events that the user would select in the Triggers dialog, then you'd need an Events.xml as that defines the UI the user would use to specify the event. If, however, your plugin only needs to receive Z-Wave events from the server, your plugin doesn't need an Events.xml because it's not defining new events for the plugin's user to specify.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest