Correcting RGB Color Value Scales for FLUX LED Strip plugin devices in Indigo – Python Scripting

Standard

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[1681458792]
indigo.variable.updateValue(indigo.variables[872936515],value=unicode(int(dev.redLevel)))
indigo.variable.updateValue(indigo.variables[770189775], value=unicode(int(dev.greenLevel)))
indigo.variable.updateValue(indigo.variables[753658911], value=unicode(int(dev.blueLevel)))
indigo.variable.updateValue(indigo.variables[1059165341], 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[1681458792]
valRed = ((int(indigo.variables[872936515].value) * 100) / 255)
valGreen = ((int(indigo.variables[770189775].value) * 100) / 255)
valBlue = ((int(indigo.variables[753658911].value) * 100) / 255)
indigo.dimmer.setColorLevels(dev, int(valRed), int(valGreen), int(valBlue), 0)

So far, this seems to be working properly.

Nexlud LED Strips for TV Backlight and Home Automation (Magic Home)

Standard

This post contains Amazon Associate links. If you purchase something through them I may get a small commission, which helps cover the hosting costs for this blog.

LED Strip01.jpg

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.

LED Strip02.jpg

Restarting an Active Plugin in Indigo 7 – Python Scripting

Standard

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.

 

 

Logitech Harmony Companion All in One Remote Control

Standard

This post contains Amazon Associate links. If you purchase something through them I may get a small commission, which helps cover the hosting costs for this blog.

Last year, after we moved, I grew tired of having to hunt for all of the various remotes every time we wanted to watch one of the two main TVs in our home. Our toddler had a habit of tossing the remotes under the couch, beds or various nooks and crannies. Finally, I decided to consolidate by researching the current Logitech universal remote systems.

After some basic research I determined that the Logitech Harmony Companion would be a good fit for our needs. I would have preferred to get a Logitech universal remote with an embedded touch screen but those were well outside of our price range. The retail price of about $140 is still a bit pricy but the features made it appealing to me.

It’s capable of controlling up to eight entertainment devices; the TV with the most devices in our home has no more than five connected (including the soundbar). The system is composed of a hub (controller) and a Logitech remote. It also provides a remote IR blaster and a mobile app. The app is required to configure and update the system so you need to have a compatible phone to manage it. The mobile app also functions as a universal remote, which can be handy when our toddler has managed to hide the Logitech remote as well (or on very lazy days when you’re tired of getting up for the hundredth time and the remote itself is way, way over there on the kitchen counter).

Continue reading

Kwikset 910 Z-Wave SmartCode Electronic Touchpad Deadbolt

Standard

This post contains Amazon Associate links. If you purchase something through them I may get a small commission, which helps cover the hosting costs for this blog.

 

A while back I decided to purchase a Kwikset 910 Z-Wave SmartCode Electronic Touchpad Deadbolt for one of our properties so I could remotely lock and unlock one of the doors there, which is very useful when you’re trying to sell a house or if Terminix decides to just schedule a day for an inspection without actually confirming that you can be at the property on that day. The 910 currently retails for about $130 though you can find less expensive ones, typically used, on eBay (make sure that it includes the Z-Wave radio module).

Continue reading

Using a Kwikset 910 Z-Wave SmartCode Electronic Touchpad Deadbolt without the Keypad

Standard

This post contains Amazon Associate links. If you purchase something through them I may get a small commission, which helps cover the hosting costs for this blog.

Normally I would first provide a post with general information about a product like this before diving straight into a tip or modification but I seem to be missing some photos so here it is…

It is possible to use a Kwikset 910 Z-Wave SmartCode Electronic Touchpad Deadbolt without the keypad and provided lock and instead use it with almost any standard deadbolt lock. You will obviously lose the use of the keypad but the lock actuator mechanism and the Z-Wave interface are all located on the part of the lock system that is mounted to the inside part of the door.

Continue reading

Using an Aeotec Smart Strip

Standard

This post contains Amazon Associate links. If you purchase something through them I may get a small commission, which helps cover the hosting costs for this blog.

SmartStrip01

A while back I decided that it would be nice to have our son’s bedroom lamp, white noise machine and humidifier all plugged into Z-Wave automation switches. But I no longer had any free modules and this meant that I’d need to purchase three Z-Wave plug-in modules. That’s not a small cost and would require more room than was available at the outlet or involve a very ugly set of power cables.

To resolve this problem, and also reduce cost, I decided to purchase an Aeotec DSC11 Smart Power Strip. This power strip provides six power outlets with four of them controllable using Z-Wave. The four can also be controlled as a single unit to turn all of them on or off.

SmartStrip02

This turned out to work well. I have it connected to my Indigo software and also an Aeon Labs Minimote. On the Minimote one button controls only the lamp and another controlls the noise machine and humidifier as a group.

I haven’t had any problems with this device.

Using Indigo 7 for Home Automation with a Mac

Standard

Back in 2013 I moved from using a very good Windows program called mControl for home automation control over to Indigo for Mac OS. mControl worked great for my needs then but I didn’t want to dedicate an additional computer to the home automation and video recording tasks since I usually left my iMac running anyway.

Indigo looked like an excellent choice and over the years and it has indeed proven to be a great software package for home automation control from a Mac. I realized that even though I’ve blogged about some of the things that I’ve done with Indigo I haven’t really mentioned my overall experience with the software.

It’s now on version 7 and though the cost has risen this is largely due to improved software support and the inclusion of the required licensed technology needed to control Z-Wave compatible door locks. Indigo is very extensible; one can find a number of community-built plugins and it also supports scripting via Python.

I wouldn’t recommend it for someone that isn’t very tech savvy; there are other consumer appliances more suitable for basic home usage, but if you want to do anything more than have a few automated tasks (for example, anything that requires a good bit of logic and virtual devices or variables) you’ll need something like Indigo.

At our house I do use a Wink system and it works fine there but it’s not capable of doing much more than running a few automated tasks; consumer appliances (usually cloud-connected) currently don’t offer very much in this realm. But at the apartment I’m still using Indigo and have moved into some more advanced home automation interactions.

With Indigo I now have several actions that are dependent on the status of other devices, virtual devices and variables. I’m also using some Bluetooth proximity detectors to provide additional enhancements and in the past I’ve done some more interesting things that I currently don’t have setup.

I highly encourage anyone with more than a passing interest in home automation, and a Mac that you’re willing to leave powered on all of the time, to look into Indigo. The initial cost may seem high but when you consider the basic cost just to purchase a consumer appliance hub such as Wink or SmartThings, and then potential issues with any of your existing equipment, you may find that the savings aren’t really there in the long run. Indigo works with X10, Insteaon and Z-Wave devices as well as some other devices that don’t use those protocols.