Firing a plugin's Events.xml Event

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
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
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Firing a plugin's Events.xml Event

Post by travisc »

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
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Firing a plugin's Events.xml Event

Post by jay (support) »

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
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Re: Firing a plugin's Events.xml Event

Post by travisc »

Ok no prob. I'll stay tuned. Thanks
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Firing a plugin's Events.xml Event

Post by jay (support) »

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
User avatar
travisc
Posts: 346
Joined: Tue Sep 07, 2010 7:24 am
Location: Toronto, Canada
Contact:

Re: Firing a plugin's Events.xml Event

Post by travisc »

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
Locked

Return to “Extending Indigo with Plugins and Python”