Error "async_get_registry" after core 2023.5.0

Hi all,
I’m getting the following error on my Scheduler component after upgrading to core 2023.5.0 and it is also present on 2023.5.1. It seems like more people are having this issue with this core version for different custom components. Anyone know how to fix this?

Logger: homeassistant.setup
Source: setup.py:214
First occurred: 09:26:08 (1 occurrences)
Last logged: 09:26:08

Setup failed for custom integration scheduler: Unable to import component: cannot import name 'async_get_registry' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)
2 Likes

I second this ask…

Same error here.
For ecowitt

Experiencing this too in ecowitt

Logger: homeassistant.setup
Source: setup.py:214
First occurred: 04:01:00 (1 occurrences)
Last logged: 04:01:00

Setup failed for custom integration ecowitt: Unable to import component: cannot import name 'async_get_registry' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)

Found a solution for ecowitt, that might be interesting for @giga89

Full story: ecowitt moved from custom integration into core.

There are postings on how to migrate, which I still have to follow, but you can fix the custom component still applying this one-line change:

2 Likes

I was able to get it working again by manually changing some code in the init.py file of the Scheduler component.
I changed line 18 from

    async_get_registry as get_entity_registry,

to

    async_get as get_entity_registry,

and line 44 from

device_registry = await dr.async_get_registry(hass)

to

device_registry = dr.async_get(hass)

The file can be found here:

Thanks the problem is also solved in the new v3.2.15 of scheduler.

Same, the pfSense integration is throwing this error too.

Same issue with pfSense. I tried to reinstall it, but I can’t remove the pfSense.

Home Assistant 2023.6.3
Supervisor 2023.06.2
Frontend 20230608.0 - latest

This error originated from a custom integration.
Logger: aiohttp.server
Source: custom_components/pfsense/__init__.py:23
Integration: pfsense (documentation, issues)
First occurred: 27 June 2023 at 19:19:34 (2 occurrences)
Last logged: 27 June 2023 at 19:19:54

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 100, 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/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 1072, 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 813, 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/pfsense/__init__.py", line 23, in <module>
    from homeassistant.helpers.entity_registry import async_get_registry
ImportError: cannot import name 'async_get_registry' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)
Logger: homeassistant.config_entries
Source: config_entries.py:863
First occurred: 27 June 2023 at 19:19:44 (1 occurrences)
Last logged: 27 June 2023 at 19:19:44

Error occurred loading flow for integration pfsense: cannot import name 'async_get_registry' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)

Same for Unifi Protect

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 399, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/unifiprotect/__init__.py", line 122, in async_setup_entry
    await _async_get_or_create_nvr_device_in_registry(hass, entry, nvr_info)
  File "/config/custom_components/unifiprotect/__init__.py", line 135, in _async_get_or_create_nvr_device_in_registry
    device_registry = await dr.async_get_registry(hass)
                            ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'homeassistant.helpers.device_registry' has no attribute 'async_get_registry'

The HACS integration for UniFi Protect has been dead for over a year. Delete it and stop ever using it.