dmamontov / hass-ledfx

LedFx for Home Assistant
https://community.home-assistant.io/t/ledfx-deep-integration-component/366750
Apache License 2.0
44 stars 6 forks source link

[BUG] Integration not working in HA 2023.9.0 Setup failed for custom integration ledfx: Unable to import component: cannot import name 'DeviceEntryType' from 'homeassistant.helpers.entity' #25

Open dflvunoooooo opened 1 year ago

dflvunoooooo commented 1 year ago

Describe the bug The Integration will not work anymore due to the following error:

Setup failed for custom integration ledfx: Unable to import component: cannot import name 'DeviceEntryType' from 'homeassistant.helpers.entity' (/usr/src/homeassistant/homeassistant/helpers/entity.py)

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 215, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 818, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/ledfx/__init__.py", line 31, in <module>
    from .helper import build_auth, get_config_value
  File "/config/custom_components/ledfx/helper.py", line 17, in <module>
    from .updater import LedFxUpdater
  File "/config/custom_components/ledfx/updater.py", line 21, in <module>
    from homeassistant.helpers.entity import (
ImportError: cannot import name 'DeviceEntryType' from 'homeassistant.helpers.entity' (/usr/src/homeassistant/homeassistant/helpers/entity.py)

Please complete the following information:

FragMenthor commented 1 year ago

Same here!

sbach89 commented 1 year ago

This is also preventing the integration from being uninstalled.

Logger: aiohttp.server
Source: custom_components/ledfx/updater.py:21
Integration: LedFx ([documentation](https://github.com/dmamontov/hass-ledfx/wiki), [issues](https://github.com/dmamontov/hass-ledfx/issues))
First occurred: 3:00:51 PM (2 occurrences)
Last logged: 3:12:43 PM
Error handling request

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 87, in delete
    result = await hass.config_entries.async_remove(entry_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1080, in async_remove
    await entry.async_remove(self.hass)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 578, in async_remove
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 818, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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/ledfx/__init__.py", line 31, in <module>
    from .helper import build_auth, get_config_value
  File "/config/custom_components/ledfx/helper.py", line 17, in <module>
    from .updater import LedFxUpdater
  File "/config/custom_components/ledfx/updater.py", line 21, in <module>
    from homeassistant.helpers.entity import (
ImportError: cannot import name 'DeviceEntryType' from 'homeassistant.helpers.entity' (/usr/src/homeassistant/homeassistant/helpers/entity.py)
ASNNetworks commented 1 year ago

Also impossible to delete the integration.

seancmalloy commented 1 year ago

Same here. I resolved this issue by editing updater.py - removing the line importing DeviceEntryType and changing entry_type to = None. Seems to work but need to test further.

FragMenthor commented 11 months ago

Same here. I resolved this issue by editing updater.py - removing the line importing DeviceEntryType and changing entry_type to = None. Seems to work but need to test further.

Thanks, that seems to work! Any problems after?

seancmalloy commented 11 months ago

I ended up, instead of changing entry_type to none, I imported DeviceEntryType from device_registry helper (not entity). But unfortunately I'm having issues. My new issue is: AttributeError: 'LedFxLight' object has no attribute '_ActionType.DEVICE_on'.

Btw- I get this error both ways

Gurutasker commented 11 months ago

Have found the source of this error.

https://github.com/home-assistant/core/pull/98149

I believe changing to the following code resolves. However I'm still receiving the same error as @seancmalloy when trying to undertake actions. Still investigating this - could be related to a separate deprecation or issue.

Replace:

from homeassistant.helpers.entity import ( DeviceEntryType, DeviceInfo, EntityCategory, EntityDescription, )

with

from homeassistant.helpers.entity import EntityCategory, EntityDescription from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo

in updater.py