Indigo Plugins for Dummies


What was it that made us think that writing an Indigo Plugins for Dummies was a good idea? Really it's quite simple.

Every one of has gone through those dark times when we knew nothing about development, python or Indigo plugins. We glanced at the Technical Documentation wiki like it was an ancient document, written in a language that no one used any more. After many wasted hours, days and weeks we began to understand what it was saying.

We started to use words like runConcurrentThread, def startup, updatePluginPrefs and dev in normal adult conversations while others looked on at us thinking we're a) mad, b) strange or simply c) odd.

Slowly we all came to realise that what we really needed was a Rosetta Stone. Something that would remove the mystery from Indigo and let us concentrate on the real important things like making something really cool. We also know that Indigo and Python survive because of our great community where we try to help everyone out. Sure Matt and Jay rock and they've built something which is amazing but they're only two people. Perhaps we could take some responsibility and help everyone else get started and realise some great new functionality for Indigo?

So we're not altruistic. We expecting to gain something from this experience as well. The more people who can develop plugins the better Indigo is going to be and the more value we get from our license fees. We also think there are so many good ideas out there which just need a plugin.

So in this guide we're going to try to drop the geek-speak level a bit. Try and talk in normal English - well probably the US version of English because the Brits are outnumbered. I like to call it Bar Speak No one goes out for a beer and then strikes up a conversation that's full of phrases like “you need the right IDE to help you get your logic binary paths integrated to enable the parsing of an HTML file using json”


How about “get an editor that'll make it easy to see what you're doing and pull your information off the web - Oh and another pint please…” You get the idea. So as you use this guide - if you see anything that makes you think “That's not Bar Speak” then feel free to pull us up on it and we'll change it to something understandable.

So are you ready to explore Indigo and what it can really do? We hope so because once you start down this road it's a very slippery slope. I guarantee that you'll drift into being an Indigo-holic as the rest of your life just slips into insignificance…

So we're a band of 'developers'. I'm not sure that any of us intended to become hooked on plugins but you've probably used some of the stuff we've put together - Airfoil, WUnderground, NEST Home, Squeezebox Controller, Netatmo, indigoPlot, Smartphone radar and so on… Yet everyone of us started just like you're feeling now - confused, anxious, overwhelmed and trying to make that first step. You know what you want to do but how do you get started?

So we're going to show you - step by step. We're going to start from the beginning. We're going to assume that you're bringing your passion to learn and we're providing that Rosetta Stone that'll save you lots of time and effort.

Ok - so time for Tip number one (drum roll etc…)

Tip 1: Plugin development is meant to be fun - never let it take over your life

Now we've got that clear - let's get started!

Well - that was a that was a short chapter 8-O

Getting Started

Tip 2: There aren't any shortcuts - good planning makes great code

We're going to build a plugin step-by-step. That doesn't just mean how to build the plugin stuff.

So we'll look at

  1. How to get started
  2. Python basics
  3. Developing robust code
  4. Catching & dealing with errors
  5. Building a plugin
  6. Testing
  7. Support

On the way we're going to concentrate on those tips & traps that we've all had to overcome. Those things that you know you can make happen but you haven't a clue where to get started or those little problems that are lurking behind every piece of code waiting to catch you out and waste hours of your time. For example How do you change the state that's displayed against a device? Where do those icons comes from? How do you handle multiple devices? and Why won't this simple piece of python code do what I want?. The great thing for me is that working with so many Indigo Gurus I've learnt a lot from this exercise as well - not least that they aren't as perfect as I originally thought!

Sometimes you're simply too embarrassed to answer the question because everyone else looks so knowledgable and confident. What you need to remember is that we're really just as incompetent as you feel. The truth is that we've got probably six months extra experience that makes us seem good.

One thing that we all agreed on when starting this project is that good planning makes good code. We've all started by knocking out a few bits of code and then spent literally hours trying to get it to work properly. So we're going to start at the beginning by deciding what the features are, building a plan to follow and gather some information together to get us started.

But before we start I guess we'd better explain the plugin that we're going to put together. It's meant to be a simple example but it covers every single part of plugin development. If there are things that we want to show you and the example doesn't use that feature, one of the authors will draw on their own experiences and show you how they dealt with that in their work rather than talk about some theoretical programme. That way you can look at their code, see how it works and use it in your own work.

Tip 3: Steal with Pride - someone may have already thought of a solution

Ok pirating films isn't ok, bootlegging music is against the law and stealing from your local supermarket is definitely frowned upon. However, in the python world we're all great believes in the Steal with Pride principle. That doesn't mean I can simply plagarise someones hard work and pass it off as my own. Do that and you'll be exiled from the python (and Indigo) community pretty quickly. However, you're welcome to copy code so long as you give proper credit to the person who spent hours making it work. In my NEST Home project I used ideas from Travis, Autolog, Berkinet, Dave17 and Rogue to help me understand and develop great code and steal some of their hard work and ideas. Funnily enough they're all looking at me now shocked 8-O - did you really do that?

The answer is yes – but if you read my code you'll see that I've credited everyone of them along with a few non-indigo developers who helped me overcome some hurdles.

So if you're going to use someone else's work it's only polite that you let them know and credit them in your code.

Anyway back to the example.

Most of us have Dimmers in our setups so that sounds like a great place to start. Maybe we can add to their functionality by adding new features that don't appear in their normal operation but we could produce a plugin that gave them some cool features that native Indigo doesn't. I did a similar thing with my Christmas lights last year to create a cool set of sequences in the outside lights that would do some clever things as dates changed or temperatures fell below freezing.

So it's time to get started - let's have some fun!

Deciding what to do - How to get Started

developer/plugins_for_dummies.txt · Last modified: 2019/01/26 00:10 (external edit)

© Perceptive Automation, LLC. · Privacy