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

Detected code that uses str for device registry entry_type #58

Open
enoch85 opened this issue Aug 26, 2024 · 1 comment
Open

Detected code that uses str for device registry entry_type #58

enoch85 opened this issue Aug 26, 2024 · 1 comment

Comments

@enoch85
Copy link

enoch85 commented Aug 26, 2024

2024-08-26 05:45:33.391 ERROR (SyncWorker_9) [custom_components.greenely.api] Failed to fetch produced electricity data, {"title":"404 Not Found","jwt":"eyJ0secretsecretsecretsecretsecretsecretJ9.eyJsecretsecretsecretsecretsecretsecretsecretsecretsecret"}
2024-08-26 05:45:33.392 WARNING (MainThread) [homeassistant.helpers.frame] Detected code that uses str for device registry entry_type. This is deprecated and will stop working in Home Assistant 2022.3, it should be updated to use DeviceEntryType instead. Please report this issue.

Stack (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 770, in _async_add_entity
    device = dev_reg.async_get(self.hass).async_get_or_create(
  File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 824, in async_get_or_create
    report(  # type: ignore[unreachable]
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 151, in report
    _LOGGER.warning(msg, stack_info=True)
    ``
@Banditen01
Copy link

Banditen01 commented Nov 25, 2024

I think this can be the solution for above matter, I made those changes and it seems to work.

First import new DeviceEntryType:
from homeassistant.helpers.device_registry import DeviceEntryType
Then change
“entry_type” : “service”,
to
“entry_type” : DeviceEntryType.SERVICE,

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

No branches or pull requests

5 participants
@enoch85 @Banditen01 and others