Trumpku No. 1


vicious neurotic,
blue blood coursing in black heart.
eyes piercing with lust.

Scripting Indigo with Python

I’ve used Indigo home automation software for a few years. It’s a integrated home automation software environment for the Mac and its a solid stable and well-supported platform.

Within Indigo, it’s possible to script triggers and actions either AppleScript or Python. It’s funny - AppleScript often looks like the easier route to take. It looks more like plain English than Python. But as they say, looks are deceiving. Two bits of bad news put the nail in AppleScript’s coffin for me - as least with Indigo.

First, I kept encountering a nasty bug when trying to talk to the Indigo Server via AppleScript run outside of the Indigo environment. You can read all about it on the Indigo forums, but basically AppleScript complained that Indigo Server wasn’t running when it plainly was running. I’m not usually one for complex workarounds such as thus that were being discussed on the forums.^[For example, some users have reported that restarting the AppleEvents daemon with sudo killall -9 appleeventsd can somehow allow external AppleScript applications to address the Indigo Server. It didn’t work for me.] So, I began to give Python a consideration.

Then there’s the iffy status of AppleScript coming out of Cupertino. The recent departure of Apple’s head of Mac automation technologies and the fact that Apple dissolved the whole Mac automation team doesn’t bode well for AppleScript.

Setting up to talk to Indigo via the Indigo Plugin Host (IPH) and Python

To make it easier to address the indigohost which is buried ddep in the Application Support directory, you should just create an alias.

~|echo "alias indigohost='/Library/Application\ Support/Perceptive\ Automation/Indigo\ 7/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost'" >> ~/.zshrc
~|source ~/.zshrc

I happen to use zsh so your terminal environment may be different.

Now to try out the indigohost:

indigohost -e 'return indigo.devices.len()'

This should return the number of devices you have. Now you can script Indigo in Python both from within the Indigo client context and as an external application.

To run a Python application as a separate file, it’s just:

indigohost -x iphtest.py

Resources

Here are a few resources to get you started:

Good luck and have fun!

Going "low information"

In the wake of Donald Trump’s victory in the U.S. presidential election, Republicans are taking the opportunity to scold progressives about living in an echo chamber and failing to take a moment to sample thought patterns of the Right.

Well I did, but I came to the conclusion that most is still complete rubbish. In fact, according to Sturgeon’s Law, 90% of everything is crap. So don’t take it personally.

Extracting mp3 file from web page with Python and ApplesScript

As I’ve mentioned before I use Anki extensively to memorize and practice Russian vocabulary. With language learning in particular, adding spoken pronunciations to the cards makes an enormous difference. Since I use Open Russian extensively to provide information to built my Anki cards, it’s a natural source of audio data, too. To optimize my learning time, I built two small scripts to grab and rename the audio files from the Open Russian site. First, I’ll describe my workflow.

How to tell if you're being pandered to

You might be the subject of political pandering if:

1. Fear, uncertainty, and doubt are the main tricks in the politician’s kit.

A politician who never tires of scapegoating a feared group, or a feared outcome is undoubtedly pandering. Or a demagogue. Or both. Whether it’s Mexicans, or Jews, or Muslims, or gay people, they never seem to stop talking about why you should be afraid of someone or something.

Well that has a familiar ring to it

The U.S. has become well-rehearsed in its response to mass shootings. An event. The pondering over terrorism vs. generalized craziness. The outpouring of prayers and support. Then the internet outrage. And more internet outrage. More meme pictures about guns and love. More color-your-profile picture trends. Empty scripted responses from pious politicians. A week or two, then back to our regularly scheduled programming.

News flash: this isn’t getting better. It’s not going to get better.

EC: An Environment Canada data plugin for Indigo

Environment Canada

Indigo is a well-known home automation controller software package for Mac OS X. I’ve written a plugin for Indigo 6 that allows you to create a virtual weather station from Environment Canada data. If you live in Canada, this will be a useful way of using weather data in your Indigo rules. For example, you could use wind and temperature data to adjust your irrigation schedule.

You can download the plugin from its git repo. After downloading the files, you’ll just need to configure them as a plugin. To do this, create a new folder and rename it EC.indigoPlugin. Copy the Contents folder that you just downloaded. Right-click on the EC.indigoPlugin bundle and Show Package Contents. Paste the Contents folder here. To install in Indigo, double-click the bundle file.

Using Python and AppleScript to get notified if a site is down

I manage a handful of websites, like this one. Having built a few on other platforms, such as Drupal, I’m familiar with the dreaded error “The website encountered an unexpected error. Please try again later.” On sites that I don’t check on frequently, it can be an embarrassment when people begin emailing you with questions about the site being down.

I wrote the following Python script to deal with the problem:

Dynamic UI lists in Indigo 6

Indigo 6 is a popular home automation controller software package on the Mac. Extensibility is one of its main features and it allows users to add a range of features to suit their needs.

Using Python scripting, users can create plugins that provide extended functionality. These plugins can provide a custom configuration UI to the user. Since the documentation around a particular feature - dynamic lists was lacking, I’ve written up my approach here.