Skip to content

Commit

Permalink
Added "actual" parameter to the estimate function
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenOpposite committed Jun 20, 2024
1 parent 8acc01c commit 9f84e7e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/forecast_solar/forecast_solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,14 @@ async def validate_api_key(self) -> bool:

return True

async def estimate(self) -> Estimate:
async def estimate(self, actual: float = 0) -> Estimate:
"""Get solar production estimations from the Forecast.Solar API.
Args:
----
actual: The production for the day in kWh so far. Used to improve
the estimation for the current day if an apikey is provided.
Returns
-------
A Estimate object, with a estimated production forecast.
Expand All @@ -197,11 +202,11 @@ async def estimate(self) -> Estimate:
if self.damping_morning is not None and self.damping_evening is not None:
params["damping_morning"] = str(self.damping_morning)
params["damping_evening"] = str(self.damping_evening)
data = await self._request(
f"estimate/{self.latitude}/{self.longitude}"
f"/{self.declination}/{self.azimuth}/{self.kwp}",
params=params,
)

url = f"estimate/{self.latitude}/{self.longitude}/{self.declination}/{self.azimuth}/{self.kwp}"
if self.api_key is not None:
url += f"?actual={actual}"
data = await self._request(url, params=params)

return Estimate.from_dict(data)

Expand Down

0 comments on commit 9f84e7e

Please sign in to comment.