feat(pvforecast): send plane horizon to Forecast.Solar

A plane's userhorizon uses the same convention as the Forecast.Solar
horizon query parameter (evenly distributed heights in degrees, starting
north, clockwise), so pass it through instead of dropping it. Without it
a shaded plane is forecast as if it had a free horizon.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Andreas
2026-09-03 17:53:22 +02:00
co-authored by Claude Opus 5
parent 57d2917c0c
commit 8926cc7ae0
2 changed files with 32 additions and 1 deletions
+22
View File
@@ -127,3 +127,25 @@ def test_request_forecast_raises_on_http_error(pvforecast_instance):
with pytest.raises(RuntimeError) as exc_info:
pvforecast_instance._request_forecast(force_update=True)
assert "Failed to fetch pvforecast from Forecast.Solar" in str(exc_info.value)
def test_plane_url_passes_userhorizon(config_eos):
"""A plane's userhorizon is forwarded as the Forecast.Solar horizon parameter."""
_config(
config_eos,
planes=[
{
"surface_tilt": 87.9,
"surface_azimuth": 175.0,
"peakpower": 13.11,
"userhorizon": [28.0, 34.0, 32.0, 60.0],
}
],
)
pv = PVForecastForecastSolar(
config=config_eos.load, start_datetime=pendulum.datetime(2025, 1, 1, tz="UTC")
)
with patch("requests.get", return_value=_http({})) as mock_get:
pv._request_forecast(force_update=True) # type: ignore
url = mock_get.call_args[0][0]
assert url.endswith("/estimate/52.5/13.4/87.9/-5.0/13.11?horizon=28.0,34.0,32.0,60.0")