Make your lights turn on, off, change their brightness and color temperature automatically.
There are many blueprints that already do the same thing, partly or with other (often unnecessary) features.
Blackshome's blueprint is awesome, but some features are unnecessary for the simplest use cases, and if something goes wrong it is hard to debug due to the many branches and edge cases. My blueprint is definitely not as smart, it only does one thing but tries to do it as well as possible.
It turns lights on or off and changes their brightness according to a motion and light sensor, and changes their color temperature according to the sun’s position. That’s all.
It doesn’t handle any edge cases. If you need a reversed light sensor, a manual conditional switch, RGB party lights, or anything fancy: use another blueprint. I recommend Blackshome's blueprint, it is well tested and documented.
Add the blueprint to Home Assistant: Using automation blueprints (really read it if you never used a blueprint).
Then the automation configuration is (or at least should be) self-explanatory.
This blueprint tries to follow the KISS principle, anyone with basic knowledge of Home Assistant automation should be able to understand and troubleshoot it.
Here is how values are computed:
- Brighter when ambient light is low
- Dimmer when ambient light is high
- Adjusts brightness smoothly between defined limits
max_b - (lux - low) * (max_b - min_b) / (high - low)
This formula linearly decreases brightness from max_b to min_b as the measured light (lux) increases between the low and high thresholds. If the light level is below low, brightness is set at max_b; if it’s above high, it’s clamped to min_b.
Example:
- lux = 45
- low = 15
- high = 200
- min_b = 20
- max_b = 100%
100−(45−15)×(100−20)/(200−15)
=100−30×80/185
=100−12.97
=87%→ The lights are set to 87% brightness since the room is quite dark (depend on sensors).
- Warm when the sun is low (sunrise/sunset)
- Cooler as the sun rises higher
- Follows a smooth nonlinear curve based on solar elevation
min_ct + (max_ct - min_ct) * ( (elevation - e_min) / (90 - e_min) ) ** gamma
This equation maps the sun’s elevation to a color temperature between min_ct (warmest) and max_ct (coolest).
The elevation is first clamped between e_min (civil twilight) and 90° (sun at zenith), then normalized to a 0–1 scale.
The gamma value controls how quickly the color temperature transitions: lower gamma keeps the temperature warmer for longer; higher gamma shifts more quickly toward cooler tones.
Examples:
- Sun is low in the sky:
- elevation = 12°
- e_min = -6°
- min_ct = 2000 K
- max_ct = 4000 K
- gamma = 0.8
norm = (12 - (-6)) / (90 - (-6)) = 18 / 96 = 0.1875
ct = 2000 + (4000 - 2000) (0.1875 ** 0.8)
= 2000 + 2000 0.261
≈ 2000 + 522
≈ 2522 K
→ The lights are set to ~2520 K, very warm because the sun is still low.
- Sun is near zenith:
- elevation = 75°
- e_min = -6°
- min_ct = 2000 K
- max_ct = 4000 K
- gamma = 0.8
norm = (75 - (-6)) / (90 - (-6)) = 81 / 96 = 0.84375
ct = 2000 + (4000 - 2000) (0.84375 ** 0.8)
= 2000 + 2000 0.873
≈ 2000 + 1746
≈ 3746 K
→ The lights are set to ~3750 K, cooler as the sun is high.
- Release a working blueprint
- Improve logic for color temperature
- Decide if adding an override sensor is fancy or not
Issues and pull requests welcome.

