Table of Contents

Indigo Server Plugin Tutorial

Note most of the code examples below are calling methods on the object self. In this context, self is meant to be the Plugin instance as defined inside the plugin.py file. To execute the sample code outside of Plugin instance methods use the indigo.activePlugin object instead.

Important: For simplicity some of the samples below specify objects based on name (“office desk lamp”). However, the preferred lookup mechanism is to use the object's ID which can be retrieved by control-clicking on the object name in Indigo's Main Window. By using the ID you ensure the object will be found even if its name is changed.

Indigo Plugin SDK Source Code Examples

The Indigo Plugin SDK (available here) includes example plugins with full XML and python source. They are a great place to start when developing new plugins.

Included in the SDK are examples that create plugin based relay, dimmer, thermostat, and custom devices. Also included is an example showing basic Indigo database traversal, how to catch low-level X10/INSTEON messages, and how to create an Indigo telnet server using the python twisted framework.

We'll be adding additional example plugins in the future.

Other Useful Plugin Source Code Examples

Additionally, below is a table of common plugin tasks and built-in plugins that implement those tasks in some form or another (from simplest to most complex):

Plugin task Plugin that illustrates an approach
Parsing XML from an IP source NOAA Weather, WeatherSnoop
Integrating with native Mac Apps Airfoil
Sending RS232 (serial port & network serial port) Commands EasyDAQ
Reading RS232 (serial & network serial port) Input EasyDAQ
Interacting with an IMAP mail server iCal Alarm Processor
Creating custom devices with states Simple: NOAA Weather, WeatherSnoop - Complex: EasyDAQ, iTunes
Creating custom actions Growl, Action Collection
Creating custom events Airfoil

Each of these plugins is installed by default with Indigo 5 - in the /Library/Application Support/Perceptive Automation/Indigo 5/Plugins (Disabled)/ folder. To see the various XML and python source files, just right-click on it in the Finder and select Show Package Contents.

Both the SDK example plugins and the plugins included with Indigo above are great places to see working examples of plugins and their source code.

How to Read and Write Plugin Preferences

FIXME (useful, but very rough notes below)

How to Add Plugin Metadata to Devices, Trigger & Scheduled Events, Variables, etc.

FIXME (useful, but very rough notes below)

Creating a Custom Plugin Device

FIXME (useful, but very rough notes below)

Creating a Custom Plugin Trigger Event

FIXME Explain Events.xml. Show example plugin subclasses of functions: triggerStartProcessing, triggerStopProcessing, didTriggerProcessingPropertyChange. Note it works very similarly to devices.

Monitoring Device State Changes from a Plugin

FIXME (useful, but very rough notes below)

FIXME Give examples of using indigo.devices.subscribeToChanges() and plugin subclasses of functions: deviceCreated, deviceDeleted, deviceUpdated.

Monitoring Changes to Variables, Triggered & Scheduled Events, Action Groups, and Control Pages

FIXME (useful, but very rough notes below)

FIXME Give examples of using indigo.*.subscribeToChanges() and plugin subclasses of functions: variableCreated, variableDeleted, variableUpdated, triggerCreated, triggerDeleted, triggerUpdated, scheduleCreated, scheduleDeleted, scheduleUpdated, actionGroupCreated, actionGroupDeleted, actionGroupUpdated, controlPageCreated, controlPageDeleted, controlPageUpdated.