springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
114 stars 39 forks source link

Error calculating charge_limit #8

Closed macray76 closed 1 year ago

macray76 commented 1 year ago

Errors being generated once target SoC has been set (e.g. first charge window 23:30, initial target SoC set at 23:04, errors start appearing from 23:09 onwards). Predbat stops the current cycle after generating this error...

2023-05-31 23:09:28.550241 WARNING pred_bat: ------------------------------------------------------------ 2023-05-31 23:09:28.550859 WARNING pred_bat: Unexpected error in worker for App pred_bat: 2023-05-31 23:09:28.551057 WARNING pred_bat: Worker Ags: {'id': '59e7d07f2e0f480d9ec0c6952185feb7', 'name': 'pred_bat', 'objectid': 'dbe1e7dd995a4ba58ff99662476fac52', 'type': 'scheduler', 'function': <bound method PredBat.run_time_loop of <predbat.PredBat object at 0x7f5b96148950>>, 'pin_app': True, 'pin_thread': 1, 'kwargs': {'interval': 300, '__thread_id': 'thread-1'}} 2023-05-31 23:09:28.551512 WARNING pred_bat: ------------------------------------------------------------ 2023-05-31 23:09:28.552965 WARNING pred_bat: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"])) File "/config/appdaemon/apps/predbat.py", line 2401, in run_time_loop self.update_pred() File "/config/appdaemon/apps/predbat.py", line 2098, in update_pred self.charge_limit = [self.current_charge_limit self.soc_max / 100.0 for i in range(0, len(self.charge_window))] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/appdaemon/apps/predbat.py", line 2098, in self.charge_limit = [self.current_charge_limit self.soc_max / 100.0 for i in range(0, len(self.charge_window))]


TypeError: can't multiply sequence by non-int of type 'float'

2023-05-31 23:09:28.553132 WARNING pred_bat: ------------------------------------------------------------

Line 2080 originally has: self.current_charge_limit = inverter.current_charge_limit

I've temporarily fixed it by converting it to a float: self.current_charge_limit = float(inverter.current_charge_limit)

Also possibly linked to this (maybe an error somewhere else or due to my "float" change) a warning on the main appdaemon.log:

2023-06-02 02:44:02.541499 INFO pred_bat: WARN: Return bad value number.givtcp_ce1234g567_target_soc from soc_percent 2023-06-02 02:44:02.543557 INFO pred_bat: Inverter 0 Current SOC is 100.0 % and new target is 29 % 2023-06-02 02:44:02.582685 INFO pred_bat: Inverter 0 Current reserve is 29.0 already at target

The above can't seem to read the inverter's current target SoC so it constantly sets it to the expected 29% target every 5 minutes even though it is already set to 29%.

springfall2008 commented 1 year ago

Please confirm the fix and I will resolve

mervin39 commented 1 year ago

Not OP but this fixes it for me

macray76 commented 1 year ago

Please confirm the fix and I will resolve

Will check this evening as for me the issue only presented itself once the initial target SoC was set by Predbat.

macray76 commented 1 year ago

Looks like this issue was fixed. Thank you!