Keep Room At Specific Lux Through Automatic Lighting

Hey friends!

As almost everyone here, I automated my lights. Having dimmers in the rooms, I would like to smoothly bring in the lights, when it gets darker and reduce it when it gets lighter again - also on dark days.

The goal is to always have a sane lighting in the room so I can work there. But if it is a bright sunny day, I don’t want the synthetic lights on and enjoy the sun instead. I see three ways here:

  1. Measure the outside luminance and map it to the light level percentage:
    100% Lights when outside luminance 40 Lux or below
    0% Lights when outside luminance 200 Lux or above
    Linear interpolation between those points

  2. Measure the inside room luminance and map it to the light level percentage:
    100% Lights when room luminance below 100 Lux
    0% Lights when room luminance over 140 Lux
    Linear interpolation between those points

  3. Measure the inside room luminance using a PID Controller to slowly adapt the light level percentage until the desired luminance is reached

The first solution is pretty easy. It gets dark outside and the lights will turn on. Not as instantanously as with a switch but smooth. The downside is, that I can not assure that it will not get too light or dark in the room, as the outside luminance is completely decoupled from the real room luminance. So there might be some undesired breaks in the lighting curve.

The second solution is very hard to use, because after turning the light on, the room gets so light, that it will turn down again, causing it to turn it up again. It works when changing the lighting really really slowly (over 2 minutes or something). But this feels weird and does not ensure the room luminance. It just compresses the dynamics of the light. So it’s never fully dark and never fully bright.

The third solution is the most complex one, but very promising. By choosing the right values for P, I and D great differences between the desired and the actual state will be changed fast, while smaller differences get only very slight changes. Also the Dimmer percentage is completely decoupled from what the luminance is. A PID Controller will just tune the dimmer until the luminance is like desired.

As I am very unhappy with the seconds solution, I move to the first one now. The perfect solution would be the PID Controller, but I have no idea how to implement this in openHAB.

How do you solve your lighting? Are you trying to achieve similar goals or is my goal to iver-engineered?

I’m looking forward to your thoughts and hints! :slight_smile:

Number two should work if you use relative values.

So measure the lx and the adjust the dimmer to compensate the difference to the desired brightness (if it is bigger than a certain threshold). In order for this to work you would need a linear mapping for the dimmer (e.g. 0% = 0lx, 10% = 10lx, 50%=50lx,…).

You can do this in a rule that triggers on lx change and checks if the switch is on before calculation.

1 Like

You mean like measuring the difference between the actual and the desired luminance, dimming down ~5%, wait a few seconds, measure again and repeat until it’s correct?

That actually is a nice idea and implements the I (Incremental) part of a PID controller. Could be worth a try. This would also be very easy to do in a lambda/function. Thanks :slight_smile:

When you get it to work the community would benefit from a tutorial in the Examples and Tutorials section.

Simply trigger the calculation on brightness sensor change and try to correct it once. This will trigger another brightness change and your rule will again be triggered. You just have to make sure that the difference exceeds a certain threshold before trying to correct the brightness as otherwise this will go on indefinitely. And make sure you only do the calculation when the switch is on.

Interesting. The hue sensors have lux detection and I think they can do something similar tin that they use the light levels to determine what to do.

I actually have my system setup to do almost the opposite of what you have suggested but in a crude scene based way. In the day if I turn on the light I want it to be turned up to max because if the daylight isn’t enough then I need more. In the evening the brightness turns down and I remove blue hue from the output so I don’t mess up my sleep schedule.

I like your idea of linking things to light levels but would suggest that you have once scene that has constant light as you suggest and another that does get dimmer in the evening otherwise you’ll mess up your circadian rythm