Skip to content

Trigger Specific Methods

didTriggerProcessingPropertyChange()

Much like it's device counterpart above (didDeviceCommPropertyChange()), this method gets called by the default implementation of triggerUpdated() to determine if any of the properties needed for recognizing an event have changed. The default implementation checks for any changes to any properties.

Method

Method Name Required
didTriggerProcessingPropertyChange(self, origTrigger, newTrigger) No

Parameters

Parameter Description
origTrigger an indigo.Trigger object representing the trigger before the change
newTrigger an indigo.Trigger object representing the trigger after the change

Return Value:

Type Description
bool True if processing-relevant trigger properties changed; False otherwise.

Exceptions Raised

Type Description

Command Syntax Examples

def didTriggerProcessingPropertyChange(self, origTrigger, newTrigger):
    some_property_changed = (origTrigger['some_prop'] == newTrigger['some_prop'])
    if some_property_changed:
        # Implement any actions required if your target property changed.
        return True
    else:
        return False

triggerCreated()

This method will get called whenever a new trigger defined by your plugin is created. In many circumstances, you won't need to implement this method since the default behavior (which is to call the triggerStartProcessing() method if it's your trigger, and it's enabled) is what you want anyway (see the triggerStartProcessing() method above for details). However, if for some reason you need to know when a trigger is created, but before your plugin is asked to start watching for the appropriate conditions, this method can provide that hook. If you implement this method, you'll need to either call triggerStartProcessing() or duplicate the functionality here.

You can also have this method called for triggers that don't belong to your plugin. If, for instance, you want to know when all triggers are created (and updated/deleted), you can call the indigo.triggers.subscribeToChanges() method to have the IndigoServer send all trigger creation/update/deletion notifications. As with other change subscriptions, this should be used very sparingly since it's a lot of overhead both for your plugin and, more importantly, for the IndigoServer.

Method

Method Name Required
triggerCreated(self, trigger) No

Parameters

Parameter Description
trigger an indigo.Trigger object representing the trigger that was created

Return Value:

Type Description
None This method does not return a value.

Exceptions Raised

Type Description

Command Syntax Examples

def triggerCreated(self, trigger):
    self.triggerStartProcessing(trigger)

triggerDeleted()

Complementary to the triggerCreated() method described above, but signals trigger deletes. The default implementation just checks to see if the trigger belongs to your plugin and if so calls the triggerStopProcessing() method. If you implement this method you'll need to call triggerStopProcessing() yourself or duplicate the functionality here.

Method

Method Name Required
triggerDeleted(self, trigger) No

Parameters

Parameter Description
trigger an indigo.Trigger object representing the trigger that was deleted

Return Value:

Type Description
None This method does not return a value.

Exceptions Raised

Type Description

Command Syntax Examples

def triggerDeleted(self, trigger):
    self.triggerStopProcessing(trigger)

triggerStartProcessing()

If your plugin defines events, this is likely the place where you'll want to do the work to start watching for those events to occur. For instance, let's say that you have an event for a plugin update, then you'll want to periodically check your site to see if there's a new version available. This is where you'd start that process. When conditions are met in your plugin for a trigger to be executed, you would call indigo.trigger.execute(triggerReference) to tell the Server to execute the trigger (and it's conditions).

Method

Method Name Required
triggerStartProcessing(self, trigger) No

Parameters

Parameter Description
trigger an indigo.Trigger object representing the trigger

Return Value:

Type Description
None This method does not return a value.

Exceptions Raised

Type Description

Command Syntax Examples

def triggerStartProcessing(self, trigger):
    self.active_triggers[trigger.id] = trigger

triggerStopProcessing()

This is the complementary method to triggerStartProcessing() - it gets called when the event should no longer be active/enabled. For instance, when the user disables or deletes a trigger, this method gets called.

Method

Method Name Required
triggerStopProcessing(self, trigger) No

Parameters

Parameter Description
trigger an indigo.Trigger object representing the trigger

Return Value:

Type Description
None This method does not return a value.

Exceptions Raised

Type Description

Command Syntax Examples

def triggerStopProcessing(self, trigger):
    if trigger.id in self.active_triggers:
        del self.active_triggers[trigger.id]

triggerUpdated()

Complementary to the triggerCreated() method described above, but signals trigger updates. You'll get a copy of the old trigger object as well as the new trigger object. The default implementation of this method will do a few things for you: if either the old or new trigger are triggers defined by you, and if the trigger type changed OR the communication-related properties have changed (as defined by the didTriggerProcessingPropertyChange() method - see above for details) then triggerStopProcessing() and triggerStartProcessing() methods will be called as necessary.

Method

Method Name Required
triggerUpdated(self, origTrigger, newTrigger) No

Parameters

Parameter Description
origTrigger an indigo.Trigger object representing the trigger before the change
newTrigger an indigo.Trigger object representing the trigger after the change

Return Value:

Type Description
None This method does not return a value.

Exceptions Raised

Type Description

Command Syntax Examples

def triggerUpdated(self, origTrigger, newTrigger):
    indigo.PluginBase.triggerUpdated(self, origTrigger, newTrigger)