basbruss / adaptive-cover

An Adaptive Cover component for HomeAsisstant to control covers based on the sun's position
MIT License
71 stars 10 forks source link

Division by zero in calculation.py #260

Open Appesteijn opened 1 month ago

Appesteijn commented 1 month ago

What version of Adaptive Cover are you using?

2.3.2

What version of Home Assistant are you using?

2024.7.3

Checklist

Describe the issue

2024-07-19 23:34:32.261 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change
2024-07-19 23:34:32.261 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 100
2024-07-19 23:34:32.261 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.screen_juna,  position: 100, state: 100, delta position: 0, min_change: 10.0, condition: False
2024-07-19 23:34:32.261 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.screen_juna, time delta: 1:45:28.389458, threshold: 10.0, condition: True
2024-07-19 23:34:32.261 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-07-19 21:00:00, now: 2024-07-19 23:34:32.261853, now < time: False
2024-07-19 23:34:32.261 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change
2024-07-19 23:34:32.262 DEBUG (MainThread) [custom_components.adaptive_cover.const] Calculated position: 100
2024-07-19 23:34:32.262 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.screen_sven,  position: 100, state: 100, delta position: 0, min_change: 10.0, condition: False
2024-07-19 23:34:32.262 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity: cover.screen_sven, time delta: 1:39:19.593133, threshold: 10.0, condition: True
2024-07-19 23:34:32.262 DEBUG (MainThread) [custom_components.adaptive_cover.const] End time: 2024-07-19 21:00:00, now: 2024-07-19 23:34:32.262530, now < time: False
2024-07-19 23:34:32.262 DEBUG (MainThread) [custom_components.adaptive_cover.const] Entity state change
2024-07-19 23:34:32.367 WARNING (MainThread) [py.warnings] /config/custom_components/adaptive_cover/calculation.py:433: RuntimeWarning: divide by zero encountered in scalar divide
  length = ((self.h_win - vertical_position) * sin(rad(a_angle))) / sin(

2024-07-19 23:34:32.368 ERROR (MainThread) [custom_components.adaptive_cover] Unexpected error fetching adaptive_cover data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_cover/coordinator.py", line 230, in _async_update_data
    self.default_state = round(self.normal_cover_state.get_state())
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_cover/calculation.py", line 178, in get_state
    self.cover.calculate_percentage(),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_cover/calculation.py", line 442, in calculate_percentage
    return round(result)
           ^^^^^^^^^^^^^
OverflowError: cannot convert float infinity to integer

Reproduction steps

It doesn't seem to affect functionality

Diagnostics dump

No response