zachcheatham / ha-omada

Home Assistant TP-Link Omada Integration
186 stars 26 forks source link

exception in async_update #57

Closed sogood007 closed 9 months ago

sogood007 commented 1 year ago
2023-01-29 17:58:51.896 ERROR (MainThread) [homeassistant.util.logging] Exception in async_update when dispatching 'omada-update-89a8ded5f7d98c797c0690b57054fcf4': ()
Traceback (most recent call last):
  File "/config/custom_components/omada/omada_client.py", line 23, in async_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 556, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 597, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 562, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 855, in state
    value = self.native_value
  File "/config/custom_components/omada/sensor.py", line 147, in native_value
    return self._controller.api.clients[self.key].tx_rate / 1000000
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

I got this error after update to latest ha-omada. I am speculating the error is coming from my wired devices don't have tx_rate and rx_rate.

sogood007 commented 1 year ago
Exception in async_update when dispatching 'omada-update-89a8ded5f7d98c797c0690b57054fcf4': () Traceback (most recent call last): File "/config/custom_components/omada/omada_entity.py", line 111, in async_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 566, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 610, in _async_write_ha_state attr.update(self.extra_state_attributes or {}) File "/config/custom_components/omada/device_tracker.py", line 244, in extra_state_attributes return self.entity_description.extra_attributes_fn(self.controller, self._mac) File "/config/custom_components/omada/device_tracker.py", line 108, in client_attributes_fn if hasattr(client, k) and getattr(client, k): File "/config/custom_components/omada/api/clients.py", line 90, in radio return RADIO[self._raw.get("radioId")] TypeError: list indices must be integers or slices, not NoneType
Exception in async_update when dispatching 'omada-update-89a8ded5f7d98c797c0690b57054fcf4': () Traceback (most recent call last): File "/config/custom_components/omada/sensor.py", line 708, in async_update if self.update_value(): File "/config/custom_components/omada/sensor.py", line 691, in update_value next_value = self.entity_description.value_fn( File "/config/custom_components/omada/sensor.py", line 74, in client_rx_value_fn return round(controller.api.clients[mac].rx_rate / 1048576, 2) TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
Exception in async_update when dispatching 'omada-update-89a8ded5f7d98c797c0690b57054fcf4': () Traceback (most recent call last): File "/config/custom_components/omada/sensor.py", line 708, in async_update if self.update_value(): File "/config/custom_components/omada/sensor.py", line 691, in update_value next_value = self.entity_description.value_fn( File "/config/custom_components/omada/sensor.py", line 83, in client_tx_value_fn return round(controller.api.clients[mac].tx_rate / 1048576, 2) TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

I have the update version and it seems still have some issue. Looking more closely, it is complaining about the "div" op. So the clients may have tx_rate but it is NoneType .

zachcheatham commented 1 year ago

Since the entity was added before logic was added to only create entities relevant to a device, I think this is still hanging around causing issues. New logic has been added to remove entities if they aren't supported by the associated device in the latest beta. Let me know if its still causing problems.

ltheoret commented 1 year ago

Hi,

I am getting tons of these errors since the 0.4.1 update. what is the cure or the cause.

`Logger: homeassistant.util.logging Source: util/logging.py:156 First occurred: March 20, 2023 at 3:25:10 PM (154994 occurrences) Last logged: 9:18:13 PM

Exception in async_update when dispatching 'omada-update-27cda8b4ee89c431c7acaa18f6b53b70': () Traceback (most recent call last): File "/config/custom_components/omada/omada_entity.py", line 111, in async_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 603, in _async_write_ha_state attr.update(self.extra_state_attributes or {}) File "/config/custom_components/omada/device_tracker.py", line 245, in extra_state_attributes return self.entity_description.extra_attributes_fn(self.controller, self._mac) File "/config/custom_components/omada/device_tracker.py", line 108, in client_attributes_fn if hasattr(client, k) and getattr(client, k): File "/config/custom_components/omada/api/clients.py", line 90, in radio return RADIO[self._raw.get("radioId")] TypeError: list indices must be integers or slices, not NoneType` Luc

jone9618 commented 1 year ago

Hi,

I am getting tons of these errors since the 0.4.1 update. what is the cure or the cause.

`Logger: homeassistant.util.logging Source: util/logging.py:156 First occurred: March 20, 2023 at 3:25:10 PM (154994 occurrences) Last logged: 9:18:13 PM

Exception in async_update when dispatching 'omada-update-27cda8b4ee89c431c7acaa18f6b53b70': () Traceback (most recent call last): File "/config/custom_components/omada/omada_entity.py", line 111, in async_update self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 603, in _async_write_ha_state attr.update(self.extra_state_attributes or {}) File "/config/custom_components/omada/device_tracker.py", line 245, in extra_state_attributes return self.entity_description.extra_attributes_fn(self.controller, self._mac) File "/config/custom_components/omada/device_tracker.py", line 108, in client_attributes_fn if hasattr(client, k) and getattr(client, k): File "/config/custom_components/omada/api/clients.py", line 90, in radio return RADIO[self._raw.get("radioId")] TypeError: list indices must be integers or slices, not NoneType` Luc

Same here

zachcheatham commented 1 year ago

In the exception posted, it shows line 90 representing return RADIO[self._raw.get("radioId")] from version 0.4.0. In 0.4.1, this was changed to return RADIO[self._raw.get("radioId", 0)]. Be sure that the latest version is installed and if you're still seeing the issue, try removing and reinstalling the integration via HACS.

jone9618 commented 1 year ago

Done. Looks like fixed. Thanks Zach. Had upgraded to 0.4.1 previously, but uninstall/reinstall seems to have done trick. Thanks for great integration.