dala318 / nordpool_planner

nordpool_planner custom component for Home Assistant
MIT License
17 stars 4 forks source link

Division by zero #26

Open hpsopanen opened 2 months ago

hpsopanen commented 2 months ago

Used parameters: duration 3, search_length 10, accept_cost 2.0, accept_rate 1.0

Update for binary_sensor.nordpool_planner_heat_house_when_cheap fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 950, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1295, in async_device_update await hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/nordpool_planner/binary_sensor.py", line 302, in update self._update(dt.now().hour, search_length) File "/config/custom_components/nordpool_planner/binary_sensor.py", line 281, in _update sensor.nordpool.pdf self._now_cost_rate = self._np_current / min_average


ZeroDivisionError: float division by zero
dala318 commented 1 month ago

Interesting... I've looked at it and seem to be some edge-cases with zero-costs that are not properly cared for. Just fixing it should be fairly easy.