Closed bravepasta closed 2 weeks ago
Reviewing the python code in line 289 where the dev calculates the simple moving average of historical data.
avg_excess_power = int(sum(PvExcessControl.pv_history[-inst.appliance_switch_interval:]) / min([1,inst.appliance_switch_interval]))
Wouldn't be the min() method always returning 1 as the values for inst.appliance_switch_interval is an integer between 1 and 60? If the use of min() is wrong, would instead the use of max() be correct?
This bug is also present in line 298.
I think you're correct, thanks for noticing this. Will fix it asap. Seems like I didn't pay enough attention when reviewing the latest PR.
Reviewing the python code in line 289 where the dev calculates the simple moving average of historical data.
avg_excess_power = int(sum(PvExcessControl.pv_history[-inst.appliance_switch_interval:]) / min([1,inst.appliance_switch_interval]))
Wouldn't be the min() method always returning 1 as the values for inst.appliance_switch_interval is an integer between 1 and 60? If the use of min() is wrong, would instead the use of max() be correct?
This bug is also present in line 298.