I’ve added a new project page titled Home Automation with Indigo (Indigo Domotics), which focuses on my home automation projects that involve Indigo. It has some tips as well as links to various blog posts related to this project.
I ran into a very frustrating problem last night while trying to work on some scripting within Indigo for controlling the LED colors of a new LED strip. I had no problem with actually controlling colors using the built-in UI tools for updating colors, but a slightly more complex usage presented a major problem.
The issue started with a need to save the current state of the individual RGB values in the LED strip, before I apply a change, such as when a notification occurs. This is to ensure that after a notification “flash” occurs that the colors will go back to the same values they were before the notification.
Via scripting, I had no problem getting the values. The problem occured when I went to restore the values. As it turns out, I struggled with this issue most of the night until I finally figured out that it was a difference between how the UI treats RGB values and how they are actually stored in the device.
The problem is that I was retrieving RGB values that were based on a scale with a minimum of 0 and a maximum of 255, but when I passed these values back the UI was converting those numbers, incorrectly, into values on a scale of 0 to 100. Eventually, I realized that before I can restore the individual color values, I must first convert them to the UI’s scale.
In addition, and perhaps I confused this with that issue, before I figured it out, I also had problems changing the color more than once in the same script. This may have been more of a timing issue (a kind of race condition) so I split the two scripts into seperate actions with a 5 second dely for the second script.
Here’s the first script that reads the LED strip’s color values and stores them into Indigo variables. The last line changes the RGB settings to display a yellow color, for notifications.
dev = indigo.devices indigo.variable.updateValue(indigo.variables,value=unicode(int(dev.redLevel))) indigo.variable.updateValue(indigo.variables, value=unicode(int(dev.greenLevel))) indigo.variable.updateValue(indigo.variables, value=unicode(int(dev.blueLevel))) indigo.variable.updateValue(indigo.variables, value=unicode(int(dev.brightness))) indigo.dimmer.setColorLevels(dev, 100, 100, 0, 0)
The first ID used represents the Indigo ID for the LED strip. The other four IDs are for the Indigo variables. All of these devices are unique to my Indigo setup, my devices and my variables. The correct values can easily be acquired by right-clicking (or Control-click) on the item within Indigo to select the ‘Copy ID’ option.
The next part of the script restores the value of the individual color variables. It first converts each value to an integer (all Indigo variables are stored as strings, so they must be converted for this type of usage) and then do some simple math to convert the RGB values to the appropriate scale. The original equation I found had more components but I removed them since the minimum value in both scales is always zero; by removing the zeros it had no effect on the final calculation.
Note that RGB values being set should be integers as well, before being used to actually change the color values.
dev = indigo.devices valRed = ((int(indigo.variables.value) * 100) / 255) valGreen = ((int(indigo.variables.value) * 100) / 255) valBlue = ((int(indigo.variables.value) * 100) / 255) indigo.dimmer.setColorLevels(dev, int(valRed), int(valGreen), int(valBlue), 0)
So far, this seems to be working properly.
My desire to integration visual notifications into our home automation setup has remained, despite taking the color-changing LED bulb out of the setup when we moved. I recently begain toying with the same bulb and in the process I realized it might be fun, and useful, to find an LED strip that I could place behind the TV. It would add a nice atmospheric effect and also provide another source of visual indicators. I have started working on using the bulb for washing machine notifications and other events, but those notices are suppresed after 10 pm at night, and that light spends most of it’s time simply functioning as a normal lamp in the bedroom.
With any home automation setup it’s always best to ensure that a device is compatible with your controller, before purchase. Fortunately, someone had developed the FLUX LED plugin to make certain Magic Home devices available to Indigo. I decided to order a wifi and IR controlled Nexlud LED Strip Lights set, which only cost about $30.
It’s taken some work, and I had a color value conversion issue that I’ll mention in another post, but it appears to be working great. My next step is to set it to automatically turn on when the TV is powered on, and to turn it off when the TV is powered off. I’m not sure, yet, if I can accomplish this via Indigo. I test the Harmony Companion plugin, but I think it is only aware of Harmony interactions initiated within Indigo. I could be mistaken, which I’ll find out of for certain. If that doesn’t work, I’ll train the Harmony itself to interact with the device (Harmony didn’t automatically recognize this device in its database of codes).
Updated 2018/08/08: I also have it setup to be controlled via the Harmon Hub. This just required training the device to recognize the remote commands, which wasn’t difficult but did take some time to program most of the color modes. I also added control via Alexa, though now I only control the on/off state through the Hue Bridge emulation between Indigo and Alexa, instead of using the Magic Home skill.
The Indigo Smart Home platform supports plugin development. In addition to the built-in plugins, my setup also has a few custom plugins developed by third-parties. Every now and then the plugins need to be restarted (reloaded). I decided to setup a scheuled proces to restart a plugin and fortunately, this can easily be one via scripting within Indigo.
For security reasons it is only possible to reload an active plugin. One cannot load a plugin that isn’t already enabled.
The python script required to do this is very simple, within Indigo.
plugin = indigo.server.getPlugin("uk.co.greensky.flux") if plugin.isEnabled(): plugin.restart()
In this example I’m restarting the FLUX LED plugin. You’ll need to replace uk.co.greensky.flux with the appropriate plugin ID. I wasn’t able to find the plugin IDs directly within Indigo but they can be obtained by looking at the plugin filenames located in /Library/Application Support/Perceptive Automation/Indigo 7/Preferences/Plugins/ and leaving off the “.indiPref” file extension.
It seems to be human nature that most of us are uncomfortable with our backs to entrances. I’m certainly one of those folks. I’ll assure any readers that I’m not up to anything unsual in my office ,but I don’t care to have folks sneak up on me from behind. I’m not going to jump at anyone that does, but it might be startling for myself if I’m focused on a project and not aware that someone has entered my office. My current office arrangement has my back to the cubicle entrance, so I opted to purchase a small mirror, so I could place it where I could easily see people coming up from behind while I’m looking at my monitor.
As usual, I performed “extensive research” by reading several reviews on Amazon until I found a product that seemed to fit my needs, which was the Ampper Clip On Security Mirror. The mirror clips on easily, and well, and only costs about $12. It provides a good field of view and the clip, along with the flexible neck, made it easy to position well.
It’s another low-tech device that works well.
Well, I’m thinking that I might have lucked out by being able to purchase this item from Amazon. I was actually surprised that it was available to order as it is usually difficult to purchase mod chips and related hardware from commercial retailers in the U.S. Yet, I did actually receive an R4 Gold Pro Revolution.
The cartridge enables a 3DS (and other systems such as the DSi) to run homebrew software. It’s easy to use, though it requires a micro SD card in order to function and some software that must be downloaded from the manufacturer’s website. The cartridge gets around the typical mod restrictions by simply presenting itself as a valid game to the system.
On the DSi I was able to run some Nintendo Entertainment Emulators (NES). The 3DS is capable of running several others including a Super NES emulator.
Overall, I think this is a very cool upgrade for the 3DS.
I continued dealing with some audio problems after replacing the TV that our son destroyed. The audio output, when routed through the TV from different devices, often had a significant delay when playing via the soundbar. The soundbar received the audio signal over an optical cable from the TV. I tried adjusting numerous audio settings on the TV itself, as well as the connected devices, but no configuration would ensure that all devices worked without a delay (in some cases one device might be good but others experienced problems).
It’s likely that simply using the TV’s speakers would have resulted on no audio lag but that’s simply not why I have a soundbar in the first place. In order to test this problem I grabbed an old optical audio switch out of the closet and set it up with each input running into the switch. It has a single output that I connected to the soundbar. This was a manual switch, so in order to change inputs one had to turn a large dial on the device to physically change the active connection.
Sure enough, it worked without any problems. I decided to order something more modern, that could be controlled via infrared (IR) in order to allow the Harmony Companion system to handle the audio switching.
After reading through several reviews on Amazon I settled on the TNP Toslink SPDIF Digital Optical Audio Switch with Remote Control and ordered one. We’ve had this in place for a while. The product itself seems to work great but I’ve had some issues with using it in the Activities. Specifically, it doesn’t always change the source input. However, I don’t believe this is a problem with the unit itself but simpy the fact that the IR receiver for the optical switch often becomes slightly misaligned relative to the Harmony Companion IR blaster. I suspect this is the result of my son moving the soundbar from time to time. It may also be in need of some tweaking within the Activity setup as it usually works when I manually change the source via the Harmony Companion app.
Overall, I think it works well and it’s much better than the manual switch I was using. I think it will work perfectly once I take the time to rework parts of the Harmony Companion setup, including the physical location of devices.