Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity property caching seems to break some custom components #107149

Closed
ppetru opened this issue Jan 4, 2024 · 1 comment · Fixed by #107221
Closed

Entity property caching seems to break some custom components #107149

ppetru opened this issue Jan 4, 2024 · 1 comment · Fixed by #107221

Comments

@ppetru
Copy link
Contributor

ppetru commented Jan 4, 2024

The problem

After the 2024.01 release, the siku2/hass_weatherlink (and apparently others too) stopped working. See siku2/hass-weatherlink#59 for details.

After some debugging, it looks like the property caching code added in #100601 may be the reason. Specifically,
CachedProperties.__new__
doesn't seem to pass kwargs to super(). Thus, __init_subclass__ from the custom component doesn't get the arguments it expects.

Caveat: I don't fully understand all the metaclass magic at play here in both core and hass-weatherlink, and could be on the entirely wrong track.

What version of Home Assistant Core has the issue?

core-2024.1.0

What was the last working version of Home Assistant Core?

core-2024.12.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

hass-weatherlink

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.loader
Source: loader.py:842
First occurred: 4:39:10 PM (1 occurrences)
Last logged: 4:39:10 PM

Unexpected exception importing platform custom_components.weatherlink.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/weatherlink/sensor.py", line 4, in <module>
    from .sensor_air_quality import *
  File "/config/custom_components/weatherlink/sensor_air_quality.py", line 18, in <module>
    class AirQualitySensor(WeatherLinkSensor, abc=True):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 295, in __new__
    return super().__new__(mcs, name, bases, namespace)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen abc>", line 106, in __new__
  File "/config/custom_components/weatherlink/sensor_common.py", line 45, in __init_subclass__
    sensor_name = kwargs.pop("sensor_name")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'sensor_name'

Additional information

No response

@ppetru
Copy link
Contributor Author

ppetru commented Jan 4, 2024

/cc @emontnemery

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant