Firing a plugin's Events.xml Event

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Wed Jun 08, 2011 12:58 pm
travisc offline
User avatar
Posts: 346
Joined: Sep 07, 2010
Location: Toronto, Canada

Firing a plugin's Events.xml Event

If I had the following event defined in my plugin's Events.xml file:
Code: Select all
    <Event id="allPhonesHome">
        <Name>All Phones Home</Name>
    </Event>


How would I fire that event? I tried checking the wiki but I only see examples to create triggers. I might have missed something. I tried the following but it doesn't like that.
Code: Select all
indigo.pluginEvent.execute("allPhonesHome")


Thanks

Posted on
Wed Jun 08, 2011 4:34 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Firing a plugin's Events.xml Event

Haven't got that quite worked out. It will likely be something similar to the updateStateOnServer method.

We should have the details by the next beta hopefully... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jun 08, 2011 8:46 pm
travisc offline
User avatar
Posts: 346
Joined: Sep 07, 2010
Location: Toronto, Canada

Re: Firing a plugin's Events.xml Event

Ok no prob. I'll stay tuned. Thanks

Posted on
Thu Jun 09, 2011 11:37 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Firing a plugin's Events.xml Event

I gave you bad information yesterday - I wasn't really thinking very clearly and forgot what we'd decided to do. The process for executing your plugin's events is this:

  1. User creates a trigger of type plugin and selects one of your plugin events - configures it (if necessary) and saves.
  2. Indigo Server sends the new trigger object to your plugin via the various Trigger Specific Methods in plugin.py. The easiest one (parallel to the various device events) is triggerStartProcessing(self, trigger). This method is also called when the server first starts up your plugin - it will pass all triggers defined to your plugin, one at a time, through this method.
  3. Your trigger catches the trigger passed in that method and stores it off.
  4. When the conditions are met that would cause that trigger to fire (plugin implementation specific), you tell the server to execute the trigger: indigo.trigger.execute(triggerRef). Note that the execute method will allow you to optionally bypass any conditions - you should NOT do this unless you're providing some kind of override/bypass. Users will clearly want conditions to be taken into account under normal circumstances (that's the default behavior).

You will also need to implement triggerStopProcessing(self,trigger) so that you can remove disabled/deleted triggers from your list. So, the Server isn't really involved at all with the trigger firing (except to execute the trigger when you tell it to) - it only notifies your plugin of events it's supposed to be watching for and your plugin does the rest.

I'll get this added to the docs today but that's pretty much what you need to know I think.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jun 09, 2011 12:25 pm
travisc offline
User avatar
Posts: 346
Joined: Sep 07, 2010
Location: Toronto, Canada

Re: Firing a plugin's Events.xml Event

Great! I should be able to take it from there. That's very similar to how the devices work and I've got those going now.

Thanks Jay

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests