Config: Move lat/long/timezone from prediction to general

This commit is contained in:
Dominique Lasserre
2025-01-20 22:58:59 +01:00
parent 1658b491d2
commit c1dd31528b
19 changed files with 297 additions and 316 deletions

View File

@@ -91,13 +91,13 @@ class WeatherClearOutside(WeatherProvider):
response: Weather forecast request reponse from ClearOutside.
"""
source = "https://clearoutside.com/forecast"
latitude = round(self.config.prediction.latitude, 2)
longitude = round(self.config.prediction.longitude, 2)
latitude = round(self.config.general.latitude, 2)
longitude = round(self.config.general.longitude, 2)
response = requests.get(f"{source}/{latitude}/{longitude}?desktop=true")
response.raise_for_status() # Raise an error for bad responses
logger.debug(f"Response from {source}: {response}")
# We are working on fresh data (no cache), report update time
self.update_datetime = to_datetime(in_timezone=self.config.prediction.timezone)
self.update_datetime = to_datetime(in_timezone=self.config.general.timezone)
return response
def _update_data(self, force_update: Optional[bool] = None) -> None:
@@ -307,7 +307,7 @@ class WeatherClearOutside(WeatherProvider):
data=clearout_data["Total Clouds (% Sky Obscured)"], index=clearout_data["DateTime"]
)
ghi, dni, dhi = self.estimate_irradiance_from_cloud_cover(
self.config.prediction.latitude, self.config.prediction.longitude, cloud_cover
self.config.general.latitude, self.config.general.longitude, cloud_cover
)
# Add GHI, DNI, DHI to clearout data