stündliche Speicherung des Forecasts angepasst
This commit is contained in:
10
main.py
10
main.py
@@ -63,10 +63,18 @@ while True:
|
|||||||
mode_as_binary = 1
|
mode_as_binary = 1
|
||||||
db.store_data('sg_ready', {'mode': mode_as_binary})
|
db.store_data('sg_ready', {'mode': mode_as_binary})
|
||||||
|
|
||||||
if now.minute == 0 and now.second == 0:
|
if now >= next_forecast_at:
|
||||||
|
# Start der Prognose: ab der kommenden vollen Stunde
|
||||||
start_hour_local = (now + dt.timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)
|
start_hour_local = (now + dt.timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)
|
||||||
weather = weather_forecaster.get_hourly_forecast(start_hour_local, HORIZON_DAYS)
|
weather = weather_forecaster.get_hourly_forecast(start_hour_local, HORIZON_DAYS)
|
||||||
total = pv_plant.get_power(weather)
|
total = pv_plant.get_power(weather)
|
||||||
db.store_forecasts('pv_forecast', total)
|
db.store_forecasts('pv_forecast', total)
|
||||||
|
|
||||||
|
# Nächste geplante Ausführung definieren (immer volle Stunde)
|
||||||
|
# Falls wir durch Delay mehrere Stunden verpasst haben, hole auf:
|
||||||
|
while next_forecast_at <= now:
|
||||||
|
next_forecast_at = (next_forecast_at + dt.timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)
|
||||||
|
|
||||||
|
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user