DarwinsBuddy / WienerNetzeSmartmeter

A home-assistant integration supporting WienerNetze Smartmeters as sensors
121 stars 12 forks source link

TypeError "Can't override _attr_state_class in subclass" in 1.4.2 #209

Closed mundschenk-at closed 5 months ago

mundschenk-at commented 5 months ago
ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.wnsm.sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/loader.py", line 842, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 859, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/config/custom_components/wnsm/sensor.py", line 26, in <module>
from .statistics_sensor import StatisticsSensor
File "/config/custom_components/wnsm/statistics_sensor.py", line 7, in <module>
from .base_sensor import BaseSensor
File "/config/custom_components/wnsm/base_sensor.py", line 31, in <module>
class BaseSensor(SensorEntity, ABC):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 408, in __init__
wrap_attr(cls, property_name)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 380, in wrap_attr
raise TypeError(f"Can't override {attr_name} in subclass")
TypeError: Can't override _attr_state_class in subclass
maia commented 5 months ago

same issue here

manolitto commented 5 months ago

same here with HA 2024.1.3 :(

maikischa commented 5 months ago

Also here on 2014.1.3 on X86 arch

tommz74 commented 5 months ago

same issue

X86 VM Core 2024.1.3 Supervisor 2023.12.0 Operating System 11.4 Frontend 20240104.0

reox commented 5 months ago

@DarwinsBuddy is this a regression of #123 ?

W-M-B commented 5 months ago

not sure if I have the same issue, but I have the latest version installed. issue is about using a depreciate version talking about a

024-01-14 10:49:45.446 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration wienerlinien which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-14 10:49:45.446 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration wnsm which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-14 10:49:45.447 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-14 10:49:49.910 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.wnsm.sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 842, in get_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 859, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/wnsm/sensor.py", line 26, in <module>
    from .statistics_sensor import StatisticsSensor
  File "/config/custom_components/wnsm/statistics_sensor.py", line 7, in <module>
    from .base_sensor import BaseSensor
  File "/config/custom_components/wnsm/base_sensor.py", line 31, in <module>
    class BaseSensor(SensorEntity, ABC):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 408, in __init__
    wrap_attr(cls, property_name)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 380, in wrap_attr
    raise TypeError(f"Can't override {attr_name} in subclass")
TypeError: Can't override _attr_state_class in subclass
2024-01-14 10:49:49.913 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform 'wnsm.sensor': Platform not found (Exception importing custom_components.wnsm.sensor).
2024-01-14 10:49:50.976 WARNING (MainThread) [homeassistant.helpers.entity] Entity None (<class 'custom_components.hacs.update.HacsRepositoryUpdateEntity'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <UpdateEntityFeature.INSTALL|PROGRESS|RELEASE_NOTES: 21>, please create a bug report at https://github.com/hacs/integration/issues and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation
2024-01-14 10:49:50.977 WARNING (MainThread) [homeassistant.helpers.entity] Entity None (<class 'custom_components.hacs.update.HacsRepositoryUpdateEntity'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <UpdateEntityFeature.INSTALL|PROGRESS|RELEASE_NOTES: 21>, please create a bug report at https://github.com/hacs/integration/issues and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation
2024-01-14 10:49:50.977 WARNING (MainThread) [homeassistant.helpers.entity] Entity None (<class 'custom_components.hacs.update.HacsRepositoryUpdateEntity'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <UpdateEntityFeature.INSTALL|PROGRESS|RELEASE_NOTES: 21>, please create a bug report at https://github.com/hacs/integration/issues and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation
2024-01-14 10:49:50.978 WARNING (MainThread) [homeassistant.helpers.entity] Entity None (<class 'custom_components.hacs.update.HacsRepositoryUpdateEntity'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <UpdateEntityFeature.INSTALL|PROGRESS|RELEASE_NOTES: 21>, please create a bug report at https://github.com/hacs/integration/issues and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation
2024-01-14 10:49:51.201 WARNING (MainThread) [hass_nabucasa.cloud_api] Fetched https://alexa-api.nabucasa.com/access_token (400)
2024-01-14 10:49:59.514 WARNING (MainThread) [zigpy.application] Zigbee channel 11 utilization is 85.82%!
2024-01-14 10:49:59.515 WARNING (MainThread) [zigpy.application] If you are having problems joining new devices, are missing sensor updates, or have issues keeping devices joined, ensure your coordinator is away from interference sources such as USB 3.0 devices, SSDs, WiFi routers, etc.
2024-01-14 10:50:01.120 WARNING (MainThread) [homeassistant.components.homeassistant.triggers.numeric_state] Error initializing 'OG Bad Strom nach 2 h aus' trigger: In 'numeric_state' condition: entity switch.lumi_lumi_plug_mmeu01_switch_3 state 'off' cannot be processed as a number

X86 hardware lastest 2024 versions installed.

mundschenk-at commented 5 months ago

@W-M-B Only the traceback at 2024-01-14 10:49:49.910 concerns this integration (and the follow-up error at .913).

DarwinsBuddy commented 5 months ago

@DarwinsBuddy is this a regression of #123 ?

Could be. I merged some old branches. Maybe I overlooked something. Bare with me

DarwinsBuddy commented 5 months ago

It seems that home assistant is monkey patching all _attr prefixed attributes by registering them as entity attributes and moving them into the pseudo private namespace __attr see https://github.com/home-assistant/core/blob/1cdfb06d7719175bbf5c90c6787c2596afe9c4e5/homeassistant/helpers/entity.py#L374

Since they were property annotated functions instead of real class properties, this didn't work.

Fixed and going to roll out a patch version :+1:

DarwinsBuddy commented 5 months ago

Thanks to all of you for reporting that so quickly. :heart:

manolitto commented 5 months ago

Thank you for fixing that so quickly! ❤️