None

Advanced lighting effects development with OpenHAB

home automation

I have been a follower of OpenHAB for a while now and I would like to say that it is a very enjoyable and fulfilling journey. Furthermore, I believe that the ability to abstract over many of the hardware specifics is a necessity for any practical application – not even the best vendor can cover all of the bases well.

OpenHAB has seen integration of most of the smart bulbs (LiFX, Phillips Hue, etc.), which allows us to treat every light as a simple object with a colour assigned to it. This solves quite a big problem of needing to use multiple smartphone apps to just switch the light on.

However, there is undeniable value added to many of the smart bulb apps – they can blink in a rhythm of your music, they can simulate a sunset, they can behave like a lava lamp. I do not want to be missing at any of those features

The plan is following:

  1. Build a test-bed to make effects development easier
  2. Develop some nice effects
  3. Wrap into a bit more re-useable package (scripts? a binding?)
  4. Deploy & test
  5. Go back to 2.

The first goal has been fulfilled by creation of the repository containing all of the required components:

https://github.com/petrklus/openhab-moodlights

In a nutshell, the repository contains 6 lights as items, basic rule skeleton to aid development and a preview page where you can see a state of all of the lights in a nicely visual way:

Screen-Shot-2015-01-05-at-16.24.21.png

Any change on any of the RGB lights is shown on the image, allowing an at-a-glance preview of the current state of the lighting.

With a preview in place, the next step is to start development of the effects! My first item on the TODO list is creation of a lightcycler (snippets of the code can already be found in the repository). The lightcycler will have a mapping between time of the day and a light colour. On a set interval (say 30s), a transitional colour will be calculated for the exact time of the day using linear scaling between closest colour before/after the current time. This will allow nice and healthy blue to red transition when the day is coming to an end. This would constitute the simplest option – and that is using all of the lights as one colour channel. Second idea in tandem is to emulate northern lights for relaxation, a wave of colour propagating from light to light with a slow, yet visible pace.

I also realise that there are a few other considerations to think about when developing such solution – for example, I am also using my mood lighting as an automatic deep red nightlight when motion is detected and it’s dark. Therefore I would also post all of the other relevant snippets of code and theoretical ideas on how to manage the system. (For example, definition of manual/automatic/alarm states for each light and rules to transition between them.)

Let me know at @petr_io if you have further ideas or need help setting up the test environment!

Screen-Shot-2015-01-05-at-16.51.49.png

 

 

blog comments powered by Disqus