FLEXi Lighting - a flexible system for lighting scenes (Hues, dimmers, and switches)

A personal project of mine has been to get my Hue and Dimmer lights to work exactly as I want them to. I wanted to be able to easily set up a number of fully automated scenes, but also wanted to keep WAF high.

To do this, I determined that I wanted (needed?) the following:

  1. A way to easily set up X number of lighting scenes;
  2. A way to easily set up color and/or level settings for X number of lights in each scene (ideally without having to repeat entering the same settings for multiple lights) as well as the “no motion” off time for each scene;
  3. A way to quickly and easily (temporarily) override the Scene Settings with Manual settings (and revert if necessary);
  4. Flexibility in what causes the triggering of the lights on / off within any scene (e.g., Will changing to the Scene, by itself, cause lights to turn on if currently off? Or will lights stay off until a motion or contact event occurs?; Can I have a scene be triggered when only a plurality (not all) of the people in my house are home? Can I use a combination of presence Sensors and “virtual presence” switches? )
  5. A way to make sure that the correct color / level settings are ALWAYS used;
  6. New devices types for my Hue and Dimmer lights that could store scene data so that any number of SmartApps could access, edit, and use the scene data; and
  7. New devices types for my Hue and Dimmer lights that immediately conveyed (i) the current color and level settings, (ii) off time information, and (iii) scene information.
  8. Doing all of the above with a minimum number of SmartApps.

Ridiculous, I know…

Here’s what I have come up with (well, to be fair, a lot of the coolest code came from apps by @tslagle13, @Mike_Maxwell, and @geko, so thanks guys!):

  1. FLEXi Scenes SmartApp - Sets up scenes and light settings for each scenes; you set up a single “Master” FLEXiHue light (see #4 below), optionally set up “Slave” FLEXiHue lights (which will adopt the color and level settings of the “Master” Hue), “Free” FLEXiHue lights (which you can set up to have different color and level settings from “Master” Hue); “Slave” FLEXiDimmer (see #5&#6 below) lights (adopts the level of “Master”); “Free” FLEXiDimmers (can have different level from “Master”), and also basic Switches
  2. FLEXi Triggers SmartApp - Sets up requirements for who needs to be home (option to check from both / either capability.presenceSensors and FLEXiState virtual presence switches), sets up the motion and contact triggers for lights, and uses the scene-set or manually-set color, level, and “no motion” settings;
  3. FLEXiHue (Hue Connect) SmartApp - communicates with Hue Bridge and creates FLEXiHue device types for each Hue light. The FLEXi Scenes and FLEXi Triggers SmartApps both REQUIRE using this SmartApp to create the required FLEXiHue devices.
  4. FLEXiHue Device Type - each FLEXiHue device is able to store all scene-related data, is able to dynamically show the color of the Hue light, and is able to switch between scene settings and manual settings. The FLEXiHue (Hue Connect) SmartApp REQUIRES this device type.
  5. FLEXiDimmer Code / Instructions to turn any dimmer device type into a “FLEXiDimmer” device type - each FLEXiDimmer device type device is able to store all scene-related data, is able to dynamically show the color of the Hue light, and is able to switch between scene settings and manual settings. I have identified blocks of code that add the custom/ad hoc FLEXi-related attributes and methods, and instructions on where to add it in an existing device type. The FLEXi Scenes and FLEXi Triggers SmartApps both REQUIRE that any dimmer device type include this code.
  6. Example of using FLEXiDimmer Code (on Aeon Micro G2 Dimmer Device Type) - an example of using the FLEXiDimmer code (in #5 above)
  7. FLEXiState" virtual presence Device Type - can be used instead of / in addition to directly subscribing to presence sensors (which is helpful to me as I can create, using gCal and IFTTT, a “presence” for family members who do not currently carry any type of ST-enabled keyfob or a smartphone). The FLEXi Scenes and FLEXi Triggers SmartApps DO NOT require using this device type.

All of these apps, devices, code, and installation instructions may be found at https://github.com/infofiend/FLEXI_Lighting.

Please let me know if you have any questions, comments, suggestions, complaints, etc.



Wow dude… This seems awesome!!

Im gonna have to check it out this weekend!!:slight_smile:

Thanks for the shout out!

1 Like

Thanks, Tim. I couldn’t have done it without learning from your stuff.


Updated to v 1.1:

  1. FLEXiHue Connect SmartApp,
  2. FLEXiHue Bulb device type,
  3. FLEXiHue Scenes SmartApp, and
  4. FLEXiHue Triggers SmartApp.

Version 1.1 includes:
-added ability to specify (on a per scene basis) a lower percentage level for any slave Hues or slave Dimmers.
-squashed bugs
-increased perfection
-solved world hunger

All code may be found here


well done sir, well done

1 Like

And people complain that ST’s version of groovy is too restricted…


Very nice. Well done. Any chance you could add LiFX compatibility in the future?

All the SmartApps need are devices that contain the FLEXi-related custom attributes & custom commands. I think that any device can be made compatible – by adding the “FLEXi”-related code portions to the device type in the IDE. I posted that code on GitHub as well.

Let me know how it goes (I don’t have any LiFX lights to test) or if you run into any problems.

The device has to be controllable by SmartThings before any smartapp, including this one, can work with it.

My understanding is that, like TCP, LifX is a cloud to cloud integration which isn’t working very well right now.

Once LifX integration is fixed, flexi app could work with it to set up scenes, but it’s unlikely flexi app would fix the core integration issue.


What JD said. I wasn’t aware about the LiFX issue.

Thanks for the reply… I am not experiencing any issues with my LiFX bulbs. In fact i’m surprised how reliable they are when you compare them to the semi-officially supported Wemos which lose their device state daily. The only time i have issues with my bulbs are when I lose power and occasionally if I have to reboot the router.

If you PM me a copy of the code for the device type you’re using, I’ll add the FLEXi code for you.

1 Like

@tonesto7 - I modified the LiFX Bulb device type and LiFX Connect app to be able to work with this system. You can find the code here

I did not test the code, however, as I do not have any LiFX bulbs. I followed the HTTP API found here. Please let me know if you run into any trouble.

Thanks… When I get a chance tonight i will try and test it out.

When I run the FLEXI_Hue Connect Smartapp, it doesnt find my Bridge. Any ideas?

1 Like

Have you uninstalled your existing Hue (Connect) app?

I have not. What will happen to all my existing lights?

Only one smartapp can connect to the Hue Hub at once.

You will need to remove your existing lights. The FlexiHue Connect smartapp will find your Hub and you can then reconnect your lights as FlexiHue Bulb devices.

Before I do that I want to setup specific scenes based on color and lights. Will your app allow me to set any of the 16miklion colors?

I haven’t personally had time to check more than a dozen.