fboundy / pv_opt

Home Assistant PV Optimisation for Solis Inverters
MIT License
26 stars 6 forks source link

Discharge Windows having low power values #259

Closed stevebuk1 closed 1 week ago

stevebuk1 commented 2 months ago

Beta testing on the Dev branch for the IOG tariff has identified very low slot values being modelled for Force Discharge.

Investigation suggests that the issue is this area of code; this should be returning the max available discharge power within a slot but is currently returning the max solar power within a slot.

                        slot = (
                            start_window,
                            -min(
                                min(self.battery.max_discharge_power, self.inverter.inverter_power),
                                -x[kwargs.get("solar", "solar")].loc[start_window],
                                ((x["soc_end"].loc[start_window] - self.battery.max_dod) / 100 * self.battery.capacity)
                                * 2
                                * factor,
                            ),
                        )

The comma was added at 3.15.4 when adding battery max discharge power. In 3.15.3 it reads:

                        slot = (
                            start_window,
                            -min(
                                self.inverter.inverter_power - x[kwargs.get("solar", "solar")].loc[start_window],
                                ((x["soc_end"].loc[start_window] - self.battery.max_dod) / 100 * self.battery.capacity)
                                * 2
                                * factor,
                            ),
                        )

i.e with no comma between the inverter power and the solar.

Whilst removing the comma would solve the main problem, I'm still not sure its right, as I think the max discharge will be the minimum of:

1) battery power 2) Inverter power 3) charger power + any solar 4) available energy left in the battery (converted to power)

??

fboundy commented 2 months ago

This whole section of code needs tidying up as I confuse myself every time I revisit it! Will have a look.

github-actions[bot] commented 2 weeks ago

Stale issue message