fboundy / pv_opt

Home Assistant PV Optimisation for Solis Inverters
Other
27 stars 6 forks source link

"Divide by zero" warning messages in PV_Opt #254

Closed punkymuzzle closed 4 months ago

punkymuzzle commented 4 months ago

Describe the bug Receiving warnings in AppDaemon which disappear after the service is restarted, but they just keep appearing. My logfile is full of them. AppDaemon log:

/homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1)) /homeassistant/appdaemon/apps/pv_opt/solax.py:112: RuntimeWarning: divide by zero encountered in divide current = abs(round(power / self.host.get_config("battery_voltage"), 1))

I Also seem to be getting warnings in the error.log:

02:00:05 WARNING pv_opt: ------------------------------------------------------------ 12:04:19 WARNING pv_opt: ------------------------------------------------------------ 12:04:19 WARNING pv_opt: Unexpected error in worker for App pv_opt: 12:04:19 WARNING pv_opt: Worker Ags: {'id': '98c4e4e5871a4885a9af24f7b2caaf09', 'name': 'pv_opt', 'objectid': '7bc04b27a552408a878db88ed1f8e201', 'type': 'state', 'function': <bound method PVOpt.optimise_state_change of <pv_opt.PVOpt object at 0x7f73349510>>, 'attribute': 'state', 'entity': 'switch.pvopt_read_only', 'new_state': 'off', 'old_state': 'on', 'pin_app': True, 'pin_thread': 0, 'kwargs': {'__thread_id': 'thread-0'}} 12:04:19 WARNING pv_opt: ------------------------------------------------------------ 12:04:19 WARNING pv_opt: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1045, in worker funcref( File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock return f(*args, *kw) ^^^^^^^^^^^^^^ File "/homeassistant/appdaemon/apps/pv_opt/pv_opt.py", line 1531, in optimise_state_change self.optimise() File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock return f(args, **kw) ^^^^^^^^^^^^^^ File "/homeassistant/appdaemon/apps/pv_opt/pv_opt.py", line 1674, in optimise x = pd.to_numeric(x, errors="coerce").interpolate() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'numpy.float64' object has no attribute 'interpolate'

12:04:19 WARNING pv_opt: ------------------------------------------------------------ 00:32:24 WARNING pv_opt: ------------------------------------------------------------ 00:32:24 WARNING pv_opt: Unexpected error in worker for App pv_opt: 00:32:24 WARNING pv_opt: Worker Ags: {'id': 'a7afa9cf8792424c8e6c2e9aa7cca0cf', 'name': 'pv_opt', 'objectid': 'd1b0a08441c34051a0fa78d504375d5a', 'type': 'scheduler', 'function': <bound method PVOpt.optimise_time of <pv_opt.PVOpt object at 0x7f8b3a3190>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 600, '__thread_id': 'thread-0'}} 00:32:24 WARNING pv_opt: ------------------------------------------------------------ 00:32:24 WARNING pv_opt: 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 "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock return f(*args, *kw) ^^^^^^^^^^^^^^ File "/homeassistant/appdaemon/apps/pv_opt/pv_opt.py", line 1570, in optimise_time self.optimise() File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock return f(args, **kw) ^^^^^^^^^^^^^^ File "/homeassistant/appdaemon/apps/pv_opt/pv_opt.py", line 1811, in optimise self._write_output() File "/homeassistant/appdaemon/apps/pv_opt/pv_opt.py", line 2223, in _write_output self.write_cost( File "/homeassistant/appdaemon/apps/pv_opt/pv_opt.py", line 2188, in write_cost (cost["cost"].loc[: midnight - pd.Timedelta(30, "minutes")].sum()) / 100,


  File "/usr/lib/python3.11/site-packages/pandas/core/indexing.py", line 1191, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pandas/core/indexing.py", line 1411, in _getitem_axis
    return self._get_slice_axis(key, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pandas/core/indexing.py", line 1443, in _get_slice_axis
    indexer = labels.slice_indexer(slice_obj.start, slice_obj.stop, slice_obj.step)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pandas/core/indexes/datetimes.py", line 682, in slice_indexer
    return Index.slice_indexer(self, start, end, step)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6662, in slice_indexer
    start_slice, end_slice = self.slice_locs(start, end, step=step)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6885, in slice_locs
    end_slice = self.get_slice_bound(end, "right")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6812, in get_slice_bound
    raise KeyError(
KeyError: "Cannot get right slice bound for non-unique label: Timestamp('2024-07-05 23:30:00+0000', tz='UTC')"

Is this anything to be worried about? PV_Opt seems to be working (although sometimes the SoC level, charging rates etc seem to be a little weird).

punkymuzzle commented 4 months ago

Just realised there is an update available so will do this and then report back

punkymuzzle commented 4 months ago

Closed