jaroschek / home-assistant-myuplink

Custom Home Assistant integration for devices and sensors in myUplink account.
39 stars 8 forks source link

Not refreshing - Crashing instead #88

Open pszewello opened 3 months ago

pszewello commented 3 months ago

I set the refresh interval to 60 (s)... on load it get's the value from myuplink but then on refresh it's crashing:

Logger: homeassistant Source: custom_components/myuplink/number.py:52 Integration: myUplink (documentation, issues) First occurred: 2:38:23 PM (13 occurrences) Last logged: 2:53:33 PM

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 256, in _handle_refresh_interval await self._async_refresh(log_failures=True, scheduled=True) File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 412, in _async_refresh self.async_update_listeners() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 183, in async_update_listeners update_callback() File "/config/custom_components/myuplink/entity.py", line 93, in _handle_coordinator_update self._update_from_parameter(parameter) File "/config/custom_components/myuplink/number.py", line 52, in _update_from_parameter self._attr_native_max_value = parameter.max_value * parameter.scale_value


TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
jaroschek commented 3 months ago

Based on the error trace the operations to apply the scale value to the given values for the number entity fail, because the given values from the parameter seem to be of type NoneType.

To avoid the integration from crashing I secured these arithmetic operations to only be executed if the given values are not None.

I created a new release containing this change. Please give it a try: https://github.com/jaroschek/home-assistant-myuplink/releases/tag/1.2.2

On the other hand: If you set the refresh interval to 60s, this could lead to blocked requests in the API. I never observed any value to be updated more often than every 5 minutes. Do you really think you need a refresh interval of 60s? Instead I observed many occasions where the API blocked my requests temporarily although I comply with the rate limit. So may be you can also increase the refresh interval to avoid any blocked requests.

pszewello commented 3 months ago

I made slightly different changes localy in the api.py for the min max and step to always resturn something if no value available… as far as interval goes the reason to move from uplink to myuplink was the fact that you don’t have to wait 5min :) let’s see what happens at 60… i will pull the update later :)