Light sensor + curtain controllers: how do you avoid constant open/close on cloudy days?

We have a light sensor and curtain controllers at home, and I would like the curtains to close when the sun is strong and open again when it is not. In Sweden the light changes constantly - a cloud passing can swing the lux reading up and down within minutes, and I do not want the curtains moving back and forth all afternoon.

For those of you running lux-driven curtain automations: how do you smooth this out? Do you use a lux threshold with a time condition (for example “above X lux for 10 minutes”), a gap between the close and open thresholds, or something else?

And a related one: how do you handle dusk, so the evening dip in light does not trigger “open” right when you want them closed anyway?

2 Likes

The usual solution is to use a hysteresis and some duration. That is don’t open/close them at the same lux value but have a range of acceptable values and one open/close them if they are out of that range for a while

3 Likes

Good questions — and +1 to what markus said, hysteresis is the foundation. A few things I’d add from practice:

1. Separate the two thresholds widely. Don’t use a single threshold: e.g. close above ~40,000 lux, open below ~8,000 lux. The gap between the two values is what stops the flapping when a cloud edge hovers near one value.

2. Add duration, not just a threshold. Require the condition to hold for 5–10 minutes before acting. Passing clouds fail the timer; real sunshine passes it.

3. Watch out for the sensor feedback loop. If the lux sensor sits behind the curtains or in a shaded room, closing the curtains darkens the sensor itself and can immediately re-trigger an “open” — the curtains then ping-pong all afternoon. Place the sensor where the curtains don’t affect it (outdoors, or a bright window that stays uncovered), or add a cooldown so the automation ignores lux changes for ~30 minutes after each curtain action.

4. Handle dusk separately. Split it into two automations: lux-driven closing only during daytime hours (e.g. 08:00–18:00, or before sunset), plus a separate evening routine that closes the curtains at sunset regardless of lux. After that, the lux automation shouldn’t run at all — otherwise the natural evening light drop would try to “open” them right when you want them closed anyway.

In the Aqara app you can approximate this with IF/THEN plus an effective period and a delay; in Home Assistant it’s straightforward with for: durations and separate on/off thresholds.

2 Likes

I second the hysteresis idea from markus. I run Home Assistant in Docker on a Mac mini, and what works for me there is to use two separate thresholds, for example close above 25,000 lux and open below 12,000 lux. I also add a “for” duration of 10 to 15 minutes on each trigger, so a passing cloud doesn’t flip the curtains. A minimum time between movements also helps. The same pattern should work in the Aqara app’s automations if you set a wide gap between the two lux values.

I second the hysteresis idea from markus. I run Home Assistant in Docker on a Mac mini, and what works for me there is two separate thresholds, for example close above 25,000 lux and open below 12,000 lux. I also add a “for” duration of 10 to 15 minutes on each trigger, so a passing cloud doesn’t flip the curtains. A minimum time between movements helps too. The same pattern should work in the Aqara app’s automations if you leave a wide gap between the two lux values.

This is a useful resource.

I have a couple of new E1 rollers for the kitchen and have ideas to automate based on LUX and within a time period (probably triggered by a number of hours after Sunrise) where the sun’s position floods the room with dazzling sunshine.

I figured I would smooth out the LUX triggers much like we do with IR motion triggers.

1 Like