Shade Engine
All of our main windows face west, so automated shades matter here: sun tracking in the afternoon, open for the view when it’s dim, closed at night (partially — wind, cats). I ran this on the Adaptive Cover integration for Home Assistant, and I spent most of a month fighting it.
The core problem is that Adaptive Cover internalizes the policy decision: sun tracking, climate modes, weather checks, presence, manual overrides — one opaque pipeline, configured partly in a settings dialog and partly through loose toggle entities whose state silently changes behavior. When it did something surprising, the only way to answer “why did the blinds just move” was to read the integration’s source and replay recorder history. Some of the failures from a single week:
- I raised the shades three times in the half hour before sunset and each raise was reverted within minutes. The manual-override window I’d configured was dead config — detection was gated behind a separate, differently named switch that was off.
- Blinds pinned fully closed at 9 PM on a summer night because the kitchen was 25.4°C and the climate branch checks temperature before it ever looks at whether the sun is still up.
- A cover that “moved recently” gets its next command silently dropped, never retried. The kitchen shade spent a night stuck at 30% because its open command landed four seconds inside that window.
- One full-sun day the shades never moved at all. Lux peaked around 70,000, but the daily forecast said “cloudy,” and the forecast vetoes glare tracking entirely.
- The north window froze at 30% overnight because its update missed the end-of-control cutoff by nine seconds.
I compensated with more automations to tweak the state of Adative Covers. Morning raise pulled out of the integration so the shades still rise if it’s disabled. A pair of automations that turn climate mode off at sunset and back on at sunrise, just to make the summer branch unreachable after dark. A five-automation lux state machine driven by an outdoor illuminance sensor. Wrapper covers so HomeKit’s “closed” means our partial stop points. A dashboard widget just to see the true override state. Plus two bugs patched directly in the installed source, which any HACS update would revert. Four config entries, surrounded by roughly nine automations of band aids.
The project’s own README has a flow chart of the decision tree. Even at thumbnail size, the shape makes the point:
While I was creating all the scaffolding to try to nudge and influence the internal decision tree I realized that the scaffolding I created was the policy… it just had no clean way in. So I built Shade Engine, a small HACS integration that does two things and refuses to do a third:
- Calculate. Pure geometry: window azimuth, field of view, sun position → the highest shade position that keeps direct sun off the first few meters of room, published as a sensor.
- Decide — not it. Policy lives in ordinary automations. Each zone exposes one mode select (
open,glare,night, whatever you define); anything that can write a select can be a policy source, and every decision is a readable automation trace. - Actuate. Mode → target → position, with a deadband, rate limiting that defers moves instead of dropping them, and manual moves honored as a visible hold with a timestamp instead of an in-memory timer.
The lux state machine I’d built as a workaround came along unchanged — it’s just the policy layer now, writing modes instead of fighting an integration for control. When the engine declines to move a cover, a sensor attribute says why. No tracing the source or the logs to try to figure out why.
vfilby/shade-engine Sun-tracking shade control for Home Assistant with externalized policy