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

Errors homeassistant.util.loop + homeassistant.helpers.entity #24

Closed
vlad36N opened this issue Jun 6, 2024 · 6 comments
Closed

Errors homeassistant.util.loop + homeassistant.helpers.entity #24

vlad36N opened this issue Jun 6, 2024 · 6 comments

Comments

@vlad36N
Copy link

vlad36N commented Jun 6, 2024

After updating Core to version 2024.6.0.

First error:
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:1628
First occurred: 4:38:13 AM (1 occurrences)
Last logged: 4:38:24 AM

Entity None (<class 'custom_components.smartir.media_player.SmartIRMediaPlayer'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <MediaPlayerEntityFeature.VOLUME_MUTE|TURN_ON|TURN_OFF|PLAY_MEDIA|VOLUME_STEP|SELECT_SOURCE: 3976>, please create a bug report at https://github.com/litinoveweedle/SmartIR/issues and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation

Second error:
Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 4:38:13 AM (1 occurrences)
Last logged: 4:38:17 AM

Detected blocking call to open inside the event loop by custom integration 'smartir' at custom_components/smartir/init.py, line 60: with open(device_json_path) as j: (offender: /config/custom_components/smartir/init.py, line 60: with open(device_json_path) as j:), please create a bug report at https://github.com/litinoveweedle/SmartIR/issues Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 223, in 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 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 402, in async_setup_component result = await task File "/usr/src/homeassistant/homeassistant/components/media_player/init.py", line 278, in async_setup await component.async_setup(config) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 149, in async_setup self.hass.async_create_task_internal( File "/usr/src/homeassistant/homeassistant/core.py", line 828, in async_create_task_internal task = create_eager_task(target, name=name, loop=self.loop) File "/usr/src/homeassistant/homeassistant/util/async.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 319, in async_setup_platform await self._platforms[key].async_setup(platform_config, discovery_info) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 303, in async_setup await self._async_setup_platform(async_create_setup_awaitable) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 363, in async_setup_platform awaitable = create_eager_task(awaitable, loop=hass.loop) File "/usr/src/homeassistant/homeassistant/util/async.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/config/custom_components/smartir/media_player.py", line 61, in async_setup_platform device_data := DeviceData.load_file( File "/config/custom_components/smartir/init.py", line 41, in load_file if device_data := DeviceData.check_file( File "/config/custom_components/smartir/init.py", line 60, in check_file with open(device_json_path) as j:

Core 2024.6.0
Supervisor 2024.06.0
Operating System 12.3
Frontend 20240501.1
Smart IR version: 1.17.14
Using for Media Player (TV)

Everything still working, just entries in logs.

Thank you.

rafiw added a commit to rafiw/SmartIR that referenced this issue Jun 6, 2024
used async file call to solve warning:
Detected blocking call to open inside the event loop by custom
integration 'smartir' at custom_components/smartir/init.py, line 60:

litinoveweedle#24
@litinoveweedle
Copy link
Owner

Hello, thank you very much for issue and for the PR. I understand, that you fix is based on the suggested HA example:

Calling sync functions from async
If you are running inside an async context, it might sometimes be necessary to call a sync function. Do this like this:

#hub.update() is a sync function.
result = await hass.async_add_executor_job(hub.update)

Starting independent task from async
If you want to spawn a task that will not block the current async context, you can choose to create it as a task on the event loop. It will then be executed in parallel.

hass.async_create_task(async_say_hello(hass, target))

To my understanding this correct way to solve the warning introduced by HA 2024.6. Could you please only reformat PR using python black formater so it will pass CQ tests? Thank you once again.

@rafiw
Copy link

rafiw commented Jun 9, 2024

@litinoveweedle I didn't start the issue but has the same issue and uploaded a PR, in how i fixed the formatting issues.

@litinoveweedle
Copy link
Owner

@rafiw Oh, sorry, I overlooked that you are not the same person, my fault. :-) Anyway thank you for the PR. I am just finishing fix for the #23, than I will test and merge your PR and release it ASAP. Thank you once again for contribution!

@rafiw
Copy link

rafiw commented Jun 9, 2024

it's ok @litinoveweedle, thank you for continuing the development of this integration

@litinoveweedle
Copy link
Owner

The issue is now fixed in the latest beta 1.17.15b2 which is ready for the testing. If no issues are discovered it will be released in the public release in few days. Thank you for help!

@litinoveweedle
Copy link
Owner

Hello, thanks to all for help and support, this issue is now fixed in the release 1.17.15. I am closing this issue now.

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

3 participants