Fun with lights

I have had some fun over the last couple of days rewriting my lighting controller. I have to give a big thank you to @bravenel for answering several question on the app creation.

My previous version of the controller had a bunch of drop down menus to select everything. Then inside the app it was a mess of spaghetti code as I tried to handle special cases for various rooms and things like theater mode. It was not pretty.

Now there is no custom code and it can do everything from the app panel that I was doing in custom code. It is still a lot of information but I can setup any room to behave in specific ways. The lighting control code is only about 100 lines. the whole project is just over 300 lines. So much neater.

The basic design is that I have a master app that creates a child app for each room. The master app is nothing more than a container for each room.

When you create a new app it asks for some information before opening up the full display. First it asks for a room name. Then it shows the first light group and when that is named the full display is shown, I do this just to make sure the bare minimum is configured. Once those values are set you see the whole app. At the top is the lighting information for that room. By default there is one lighting group. In this example I have setup several. You can add and remov groups by using the add/delete buttons.

For my living room I use three individual groups. Most rooms just use a singe light group. My living room has a bunch of photos from my gallery so I have 30 RGBW track lights in that room alone. It is a fun lighting setup.

After the light groups you will find the lighting colors and levels. You can setup as many custom lighting levels as you wish. In addition to the white and color light options there are two special selections that don't have an entry in this section: "Circadian" which gets values from another app, and "Off" which should be obvious what it does.

I have had trouble with my track lights in the past. They didn't work as expected and I thought it was related to the HSL -> RGB conversion so I edited the driver to accept RGB values. This is why I have the RGB toggle in the app. It changes the inputs between RGB and HSL. You can mix devices in the same room. You only need to make sure you have a color setup for that mode.

Finally, below the color section is a table that crosses the hub modes and light groups.

The blue highlighted line is the current mode set on the hub. When you click on one of the cells it pops up an input field below the table so that you may set a light mode. Here you can see the two additional modes (Off and Circadian).

The only thing left to implement is the Cooldown condition. This is special to my motion zone control. My custom zone motion controller has a pseudo presence function. The more times a zone is triggered the longer it stays on after the sensors report inactive. I call this the cooldown phase.

The cooldown isn't needed but it lets me do things like dim a light when motion is no longer detected. I don't have a need for this in the living room but can see using it for things like hallways or similar areas. This will be useful for other modes I haven't setup yet (ie: guest, party, or gallery).

Overall it works great. It is more reliable than my previous app. I can setup a room in less than a minute and it can do some pretty advanced scenes without writing any code.

In case you are wondering what's up with the theater modes... When you switch the living room to theater mode it first enters the Pre stage. This sets the track lights to a cyan color at 50% and the accent lights to warm white, also at 50%. This is when things happen like the shades lower and the projector turns on. Then when the room is ready it moves to Warn mode. Here the lights drop to 1% and the accent lights change from white to magenta. This is like a theater flipping the lights in the lobby to warn that the show is about to start. Finally, when it is show time the final mode turns off the lights over the projection screen.

No real point to this long-winded writeup other than I had some fun putting the app together. :slight_smile:

7 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.