Tracking the Sun With Pergola Louvres in Home Assistant: Why Azimuth Alone Fails

Tracking the Sun With Pergola Louvres in Home Assistant: Why Azimuth Alone Fails. AutoMatter

A recent thread on the Home Assistant community forum is worth reading if you have motorised louvres, blinds or awnings and want them to follow the sun. It is not a product launch and the problem is not fully solved yet, but it shows a trap many people fall into.

What the owner was trying to do

The poster has two pergolas in the south of France, with louvre pivot axes running roughly north-south. One is rotated 15 degrees east of south and the other 15 degrees west. They are controlled through Somfy with the Overkiz integration, with a range of 0 to 100 percent open, where 100 percent means the blades sit at 115 degrees to the horizontal.

The goal is two modes. In summer, keep the pergolas in shade, which the poster found relatively easy. In winter, track the sun for maximum solar gain in the house. A pair of helper switches choose the mode, with a rule of shade above 25 °C outside and sun below.

Why the lookup table did not work

The first attempt was about 30 automations keyed on solar azimuth, and a later AI-generated version collapsed this into one automation with a long chain of azimuth thresholds. The poster’s own observation was that in the early morning, when the sun is side-on to the louvre axes, elevation matters most, and nearer midday azimuth takes over. An azimuth-only table cannot capture that. An AI chatbot suggested switching between elevation and azimuth control around a set compass angle, plus separate logic per season, which would take a year to prove.

The geometry answer suggested in the thread

Two replies pointed at the same fix: use the pergola’s own orientation instead of seasons. One suggested the maths in this order:

  • Take azimuth and elevation from Home Assistant’s sun data.
  • Shift the azimuth by the pergola’s offset, so the louvre axis counts as true north-south.
  • Place the sun on a unit sphere and discard the component along the louvre axis. Only the up-down and east-west position matters, because that is the plane the blades rotate in.
  • Use atan2 to get the sun’s angle in that plane, then clamp it and scale it linearly to the 0 to 100 percent range.
  • Repeat for the second pergola with the opposite offset.

Based on the poster’s measured readings, the same reply estimated a rough conversion of the in-plane angle A as the value (A minus 5) divided by 1.15, clamped between 15 and 100. That is a community estimate from admittedly messy data, not a verified formula, and it assumes the sun integration is accurate, the pergolas are level and percent maps linearly to angle. Another reply recommended testing the logic in the template editor with simulated azimuth and elevation values rather than waiting for the seasons to change.

What this means for your own system

  • Measure before you code. Note which way your louvre axis actually points and whether your blades are level. The geometry depends on those.
  • Check the percentage mapping. If your cover reports tilt in percent, find out whether it is linear with angle by recording the best sun-facing position at several times of day, as the poster did.
  • Prefer one calculation over many thresholds. A single template per louvre set is easier to debug than dozens of rules, and it works across seasons.
  • Test offline. Feed fake sun values into the template editor and look at the output before it moves a motor.
  • Keep a simple summer mode. Shade-keeping is the easier half. Get that stable first.

We have not tried this ourselves, and the thread had not reached a confirmed working setup when we read it. The approach is sound enough to try on any tilting louvre, blind or screen that Home Assistant can set to a tilt position. Treat the numbers as a starting point for your own calibration.

Sources