Dynamic sunlight smart bulb
Me:
Write an automation to dynamically change the bedroom lamp brightness and color temperature to match the current daylight/sun position. Also take into account weather/cloud cover/etc to account for all variables. All of the necessary entities for daylight/weather/cloud cover/sun position/etc should already be available. The ultimate goal is to have the light respond to/mimic the real-world sunlight as accurately as possible.
Additionally create a helper switch to enable/disable the automation so we can easily regain manual control any time we want.
Claude:
I'll build this properly. First, let me consult the best-practices guide and discover the available entities, since the automation should reference real entity IDs.
Now let me discover the relevant entities for sun position, weather, cloud cover, and illuminance.
The cloud results are Nextcloud noise. Cloud coverage is typically an attribute on the weather entity. Let me check the weather attributes and look for an illuminance sensor.
Cloud coverage is available as the
cloud_coverageattribute onweather.home(currently 14%), andsun.sunexposeselevation. The bulb's range is 2000K–9009K. Now let me load the helper-creation tool to build the enable/disable switch.Now I'll create the enable/disable helper switch.
The helper is created (
input_boolean.bedroom_lamp_sun_sync). Now let me validate the brightness/color-temp math against current conditions before embedding it.The math validates cleanly: at the current low evening sun (5.5° elevation, 14% cloud) it produces 20% brightness at 3044K — appropriately dim and warm. Now I'll create the automation.
The automation is created. Let me trigger it once to confirm the full chain works end-to-end.
Everything is working. The automation just ran and set the lamp to brightness 152/255 (~20%) at 2967K — matching the low evening sun.
What I built
Helper switch: input_boolean.bedroom_lamp_sun_sync ("Bedroom Lamp Sun Sync") — toggle this off any time to take full manual control of the lamp. Turn it back on and the lamp immediately re-syncs.
Automation: "Bedroom Lamp - Sun Sync" (automation.bedroom_lamp_sun_sync)
How it mimics real sunlight:
The lamp is driven by two live inputs — the sun's elevation (sun.sun) and current cloud coverage (weather.home → cloud_coverage):
- Brightness follows a daylight curve from a 2% floor (deep twilight/night) up to 100% at high sun. Cloud cover dims it by up to 45% at full overcast, mirroring how clouds reduce real ground-level light.
- Color temperature runs from a warm 2200K at twilight/night through to a cool 6500K at high midday sun (the natural golden-hour-to-daylight shift). Overcast skies add up to +700K of cooling, since overcast daylight is genuinely bluer. Clamped to the bulb's 2000–9009K range.
The elevation curve tops out around 60°, so the model is also seasonally accurate — the low winter sun naturally yields dimmer, warmer light than high summer sun.
When it updates: every 5 minutes, the moment you re-enable the helper, and on Home Assistant restart. A 5-second transition smooths each change. Mode is restart so the freshest readings always win.
A couple of things worth noting: as written, the automation will actively turn the lamp on when enabled (that's what makes it fully mimic daylight), so if you switch the lamp off but leave the helper on, it'll come back within 5 minutes — flip the helper off for true manual control. If you'd rather it only adapt the lamp when it's already on (never turning it on by itself), I can add that condition. I can also expose the tuning values (brightness floor, Kelvin range, cloud strength) as slider helpers if you want to dial in the feel without editing the automation.