Taraman17 / hass-homee

a Home Assistant custom component to integrate the homee smart home platform
MIT License
14 stars 2 forks source link

Error spamming logs - AttributeError: 'cached_property' object has no attribute 'fget' #44

Closed thargy closed 5 months ago

thargy commented 6 months ago

Type of problem

Version

Encountered in 2.8.0, 2.9.0-beta.1. Also found in 2.5.1 from @FreshlyBrewedCode.

Detailed description

I noticed random system freezes where my Memory usage went over 91G (16G RAM) when it's usually ~10G max. I checked logs and noticed that errors from pymee and homee seemed to always occur as this happened. Reinstalled latest versions (see above), and re-configured homee from scratch (after in-place upgrade did not resolve anything). However, that didn't work either, and on clean start up I get the following in logs.

The logs then continue to span AttributeError: 'cached_property' object has no attribute 'fget' from File "/config/custom_components/homee/__init__.py", line 290, in state_attributes

Error log

2024-01-05 22:53:35.034 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform homee
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1278, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1001, in __async_calculate_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/homee/__init__.py", line 290, in state_attributes
    data = self._entity.__class__.__bases__[1].state_attributes.fget(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'cached_property' object has no attribute 'fget'
2024-01-05 22:53:35.039 ERROR (MainThread) [homeassistant.components.switch] Error while setting up homee platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1278, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1062, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1001, in __async_calculate_state
    attr.update(self.state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/homee/__init__.py", line 290, in state_attributes
    data = self._entity.__class__.__bases__[1].state_attributes.fget(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'cached_property' object has no attribute 'fget'
thargy commented 6 months ago

I have confirmed that commenting out the property (Lines 287-297) not only fixes the log errors, but a bunch of entities that were missing/broken on my garage doors are now working again. I can't confirm whether the memory leak has gone, as it is intermittent, and may not be related to pymee/homee.

I could find no usage of the state_attributes property, nor homee_data attribute that got added to all entities as part of this commit; but you will probably want to review before just removing - hence I've not put in a PR.

Pr0mises commented 5 months ago

Can confirm this worked for me, switches and sensors of my garage are back. Only my cover entity was present before. Thank you

Taraman17 commented 5 months ago

Released a fix on https://github.com/Taraman17/hass-homee/tree/v2.9.0-beta.2

Taraman17 commented 5 months ago

fixed with #49