Question - automating roller blinds based on light level


I have been running HA for about 4 months now and, wow, the world has come a long way since I played with Z-Wave over a decade ago!

I currently have open / close routines configured based on time of day but would like to up my game and use the current level of brightness factor into the decision making logic. Given that I already have HUE integrated and working well, I intend to use the “Illuminance” value as a trigger to open or close the blinds.

I’m looking for guidance as to how to have an event triggered (such as too bright, close the blinds OR too dark, open the blinds) but not too have this happen to frequently. Is there a way to lock out an automation from being triggered for a set duration?

First of all, if you set up an automation to trigger below a certain value, it only triggers when going from higher to lower. Same if you trigger above, it will only trigger once, when it changes from lower to higher. So in itself, these conditions should not trigger too often.

Adittionally, but not exeactly what you asked: there’s also the trigger duration setting. You can say: ‘when it is above for longer than … time’ by entering a duration as well, which could also prevent triggering on short fluctuations:

platform: numeric_state
entity_id: sensor.lightlevel
  hours: 0
  minutes: 10
  seconds: 0
above: '200'

Myself, I use a threshold sensor, that uses a ‘hysteresis’, which is a range that the value must pass before it will turn back to the other value. The below one turns on if the light value is higher than 210, and only turns off again when the light level goes below 10:

  - platform: threshold
    device_class: light
    name: Dakschermen grenswaarde
    entity_id: sensor.lightlevel
    upper: 110
    hysteresis: 100

I operate the screen on the change of the binary sensor. That never triggers too often for me.

And then there’ s also what you actually asked (but I think you should rarely need):
If you set the automation to ‘single’ then that same automation cannot be active twice at the same time. So if you simply put a delay as the last action, the automation will be running for that period of time. It will therefore not be able to trigger again for that period of time.

Note that a HA restart or reload of the automations will kill the delay though. Timers can (since 2022.4) be set up to survive a restart, so if that is important to you you could start a timer at the end of the automation, and test if the timer is not running in the conditions. Timers are in general preferred for anything with a long period for exactly that reason. You can create timers in the helper section, and start them with the timer service.

1 Like

Firstly, thank you!

I never even thought about the hysteresis option. That’s very elegant. No problem about losing state after a reload. That won’t happen often.

1 Like

If your brightness sensor is inside and effected by your blinds, how would you avoid your blinds to open and close all the time?

It’s bright > blinds close > it’s dark, since the blinds are closed > blinds open > repeat

Same goes for internal lights.

Yeah, this idea won’t work unless it is based on the lux level of an external sensor.


I use internal room lux level to determine if my lights need to be turned on, but they only turn on based on motion and if the lux level is low enough. They they stay on for a period of time once motion stops, irrelevant of lux level. To me that seems to be the best solution since I see no point in turning lights on in my house simply because it’s dark. I don’t like to waste money on power.

1 Like

I have internal lights switching on an internal Xiaomi lux sensor. The lux sensor is barely affected by the led light, and I placed in a position that isn’t too much affected. The lux level changes from sunlight are way more then thuse from the lights, so if you use an acceptable hysteresis then you won’t have a problem. It is probably also measuring frequencies that are not present in led. I haven’t tested this with halogen light, but I think if your light sensor is placed right it won’t be that much of a problem either.

If you are controlling a sunscreen with the internal light sensor it will be a factor, because the sun shades do indeed block the sun significantly. For that I have a hue outside motion sensor with lux measurement at the back outside. (careful: Deconz did not recognise it properly - I had to tinker with all kinds of internal properties to get it working). Careful with lux sensors inside a motion sensor: many do not update the lux value if there is no motion. The hue does update it normally though.

I also have a Xiaomi at the front that isn’t waterproof (IPX3 rating). I cut the bottom of a plastic bottle, placed it upside down and put the Xiaomi sensor inside. Works like a charm too.