@@ -856,10 +856,13 @@ def in_octopus_slot(self, minute):
856856 end_minutes = min (self .mintes_to_time (end , self .midnight_utc ), self .forecast_minutes )
857857 slot ['end_minutes' ] = end_minutes
858858
859+ slot_minutes = end_minutes - start_minutes
860+ slot_hours = slot_minutes / 60.0
861+
859862 # Return the load in that slot
860863 if minute >= start_minutes and minute < end_minutes :
861- # The load expected is stored in chargeKwh for the half hour, or use the default set by the user if not which is hourly
862- return abs (float (slot .get ('chargeKwh' , self .car_charging_rate / 2.0 ))) * 2.0
864+ # The load expected is stored in chargeKwh for the period or use the default set by the user if not which is hourly
865+ return abs (float (slot .get ('chargeKwh' , self .car_charging_rate * slot_hours ))) / slot_hours
863866 return 0
864867
865868 def rate_scan_export (self , rates ):
@@ -1220,6 +1223,7 @@ def optimise_charge_limit(self, window_n, record_charge_windows, try_charge_limi
12201223 """
12211224 loop_soc = self .soc_max
12221225 best_soc = self .soc_max
1226+ best_soc_min = self .soc_max
12231227 best_metric = 9999999
12241228 best_cost = 0
12251229 prev_soc = self .soc_max + 1
@@ -1272,6 +1276,7 @@ def optimise_charge_limit(self, window_n, record_charge_windows, try_charge_limi
12721276 best_metric = metric
12731277 best_soc = try_soc
12741278 best_cost = cost
1279+ best_soc_min = soc_min
12751280 if self .debug_enable :
12761281 self .log ("Selecting metric {} cost {} soc {} - soc_min {} and keep {}" .format (metric , cost , try_soc , soc_min , self .best_soc_keep ))
12771282 else :
@@ -1284,7 +1289,7 @@ def optimise_charge_limit(self, window_n, record_charge_windows, try_charge_limi
12841289 # Add margin last
12851290 best_soc = min (best_soc + self .best_soc_margin , self .soc_max )
12861291
1287- return best_soc , best_metric , best_cost , soc_min
1292+ return best_soc , best_metric , best_cost , best_soc_min
12881293
12891294 def optimise_discharge (self , window_n , record_charge_windows , try_charge_limit , charge_window , discharge_window , try_discharge , load_minutes , pv_forecast_minute , pv_forecast_minute10 ):
12901295 """
0 commit comments