diff --git a/main.py b/main.py index e48176b..09ac01e 100644 --- a/main.py +++ b/main.py @@ -35,24 +35,7 @@ meter = SolaredgeMeter(device_name='solaredge_meter', ip_address='192.168.1.112' es.add_components(hp_master, hp_slave, shelly, wr, meter) controller = SgReadyController(es) -# FORECASTING -latitude = 48.041 -longitude = 7.862 -TZ = "Europe/Berlin" -HORIZON_DAYS = 2 -weather_forecaster = WeatherForecaster(latitude=latitude, longitude=longitude) -site = Location(latitude=latitude, longitude=longitude, altitude=35, tz=TZ, name="Gundelfingen") - -p_module = 435 -upper_roof_north = PvWattsSubarrayConfig(name="north", pdc0_w=(29+29+21)*p_module, tilt_deg=10, azimuth_deg=20, dc_loss=0.02, ac_loss=0.01) -upper_roof_south = PvWattsSubarrayConfig(name="south", pdc0_w=(29+21+20)*p_module, tilt_deg=10, azimuth_deg=200, dc_loss=0.02, ac_loss=0.01) -upper_roof_east = PvWattsSubarrayConfig(name="east", pdc0_w=7*p_module, tilt_deg=10, azimuth_deg=110, dc_loss=0.02, ac_loss=0.01) -upper_roof_west = PvWattsSubarrayConfig(name="west", pdc0_w=7*p_module, tilt_deg=10, azimuth_deg=290, dc_loss=0.02, ac_loss=0.01) -cfgs = [upper_roof_north, upper_roof_south, upper_roof_east, upper_roof_west] -pv_plant = PvWattsPlant(site, cfgs) - now = datetime.now() -next_forecast_at = (now + dt.timedelta(hours=1)).replace(minute=0, second=0, microsecond=0) while True: now = datetime.now() if now.second % interval_seconds == 0 and now.microsecond < 100_000: @@ -65,18 +48,5 @@ while True: mode_as_binary = 1 db.store_data('sg_ready', {'mode': mode_as_binary}) - 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) - weather = weather_forecaster.get_hourly_forecast(start_hour_local, HORIZON_DAYS) - total = pv_plant.get_power(weather) - 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)