dvd-dev / hilo

Home Assistant Hilo Integration via HACS
MIT License
122 stars 26 forks source link

Warning au sujet des blocking calls dans HA 2024.6.X et + #434

Closed ic-dev21 closed 1 week ago

ic-dev21 commented 3 weeks ago

Version of the custom_component

2024.6.1

A clear and concise description of what the bug is.

Debug log


Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 6:52:16 PM (18 occurrences)
Last logged: 6:53:29 PM

Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/sensor.py, line 675: with open(self._history_state_yaml, "w") as yaml_file: (offender: /config/custom_components/hilo/sensor.py, line 675: with open(self._history_state_yaml, "w") as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 188, 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/helpers/entity.py", line 941, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1289, in async_device_update await self.async_update() File "/config/custom_components/hilo/sensor.py", line 664, in _async_update self._save_history(new_history) File "/config/custom_components/hilo/sensor.py", line 675, in _save_history with open(self._history_state_yaml, "w") as yaml_file:
Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/__init__.py, line 147: api = await API.async_create( (offender: /usr/local/lib/python3.12/site-packages/pyhilo/util/state.py, line 82: with open(state_yaml) as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 188, 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/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, **request.match_info) File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 285, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 70, in wrapper return await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure result = await self._async_configure(flow_id, user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 414, in _async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 572, in _async_handle_step result = await self.async_finish_flow(flow, result.copy()) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2563, in async_finish_flow self.hass.config_entries.async_update_entry(entry, options=result["data"]) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2005, in async_update_entry self.hass.async_create_task( File "/usr/src/homeassistant/homeassistant/core.py", line 806, in async_create_task return self.async_create_task_internal(target, name, eager_start) 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 "/config/custom_components/hilo/__init__.py", line 188, in async_reload_entry await hass.config_entries.async_reload(entry.entry_id) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1897, in async_reload return await self.async_setup(entry_id, _lock=False) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1821, in async_setup await entry.async_setup(self.hass) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hilo/__init__.py", line 147, in async_setup_entry api = await API.async_create(
Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/__init__.py, line 147: api = await API.async_create( (offender: /usr/local/lib/python3.12/site-packages/pyhilo/util/state.py, line 82: with open(state_yaml) as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 188, 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 "/config/custom_components/hilo/__init__.py", line 188, in async_reload_entry await hass.config_entries.async_reload(entry.entry_id) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1897, in async_reload return await self.async_setup(entry_id, _lock=False) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1821, in async_setup await entry.async_setup(self.hass) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hilo/__init__.py", line 147, in async_setup_entry api = await API.async_create(
Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/__init__.py, line 147: api = await API.async_create( (offender: /usr/local/lib/python3.12/site-packages/pyhilo/util/state.py, line 107: with open(state_yaml, "w") as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 188, 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 "/config/custom_components/hilo/__init__.py", line 188, in async_reload_entry await hass.config_entries.async_reload(entry.entry_id) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1897, in async_reload return await self.async_setup(entry_id, _lock=False) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1821, in async_setup await entry.async_setup(self.hass) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hilo/__init__.py", line 147, in async_setup_entry api = await API.async_create(
Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/sensor.py, line 669: with open(self._history_state_yaml) as yaml_file: (offender: /config/custom_components/hilo/sensor.py, line 669: with open(self._history_state_yaml) as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 188, 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 "/config/custom_components/hilo/__init__.py", line 188, in async_reload_entry await hass.config_entries.async_reload(entry.entry_id) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1897, in async_reload return await self.async_setup(entry_id, _lock=False) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1821, in async_setup await entry.async_setup(self.hass) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hilo/__init__.py", line 172, in async_setup_entry hass.async_create_task( File "/usr/src/homeassistant/homeassistant/core.py", line 806, in async_create_task return self.async_create_task_internal(target, name, eager_start) 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/config_entries.py", line 2032, in async_forward_entry_setups await asyncio.gather( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2034, in <genexpr> create_eager_task( 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/config_entries.py", line 2081, in _async_forward_entry_setup await entry.async_setup(self.hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 134, in async_setup_entry return await component.async_setup_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 196, in async_setup_entry return await self._platforms[key].async_setup_entry(config_entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 333, in async_setup_entry return 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/hilo/sensor.py", line 173, in async_setup_entry new_entities.extend(generate_entities_from_device(d, hilo, scan_interval)) File "/config/custom_components/hilo/sensor.py", line 99, in generate_entities_from_device HiloRewardSensor(hilo, device, scan_interval), File "/config/custom_components/hilo/sensor.py", line 585, in __init__ self._history = self._load_history() File "/config/custom_components/hilo/sensor.py", line 669, in _load_history with open(self._history_state_yaml) as yaml_file:
Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 7:41:37 PM (8 occurrences)
Last logged: 7:41:37 PM

Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/__init__.py, line 147: api = await API.async_create( (offender: /usr/local/lib/python3.12/site-packages/pyhilo/util/state.py, line 82: with open(state_yaml) as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 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/config_entries.py", line 742, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hilo/__init__.py", line 147, in async_setup_entry api = await API.async_create(
Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/__init__.py, line 147: api = await API.async_create( (offender: /usr/local/lib/python3.12/site-packages/pyhilo/util/state.py, line 107: with open(state_yaml, "w") as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 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/config_entries.py", line 742, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hilo/__init__.py", line 147, in async_setup_entry api = await API.async_create(
Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/sensor.py, line 674: with open(self._history_state_yaml) as yaml_file: (offender: /config/custom_components/hilo/sensor.py, line 674: with open(self._history_state_yaml) as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues Traceback (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 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/config_entries.py", line 2032, in async_forward_entry_setups await asyncio.gather( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2034, in <genexpr> create_eager_task( 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/config_entries.py", line 2081, in _async_forward_entry_setup await entry.async_setup(self.hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 134, in async_setup_entry return await component.async_setup_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 196, in async_setup_entry return await self._platforms[key].async_setup_entry(config_entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 333, in async_setup_entry return 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/hilo/sensor.py", line 173, in async_setup_entry new_entities.extend(generate_entities_from_device(d, hilo, scan_interval)) File "/config/custom_components/hilo/sensor.py", line 99, in generate_entities_from_device HiloRewardSensor(hilo, device, scan_interval), File "/config/custom_components/hilo/sensor.py", line 590, in __init__ self._history = self._load_history() File "/config/custom_components/hilo/sensor.py", line 674, in _load_history with open(self._history_state_yaml) as yaml_file:
kayhos commented 3 weeks ago

Salut,

J'ai aussi ce comportement, voici un stack trace

Voici mes versions:

HASS: 2024.6.0 HACS: 1.34.0 Hilo: 2024.6.1

WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'hilo' at custom_components/hilo/__init__.py, line 147: api = await API.async_create( (offender: /usr/local/lib/python3.12/site-packages/pyhilo/util/state.py, line 82: with open(state_yaml) as yaml_file:), please create a bug report at https://github.com/dvd-dev/hilo/issues
Traceback (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 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/config_entries.py", line 742, in async_setup_locked
    await self.async_setup(hass, integration=integration)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/hilo/__init__.py", line 147, in async_setup_entry
    api = await API.async_create(
ic-dev21 commented 3 weeks ago

J'ai commencé à travailler là dessus un peu mais c'est pas simple avec mes skills.

kayhos commented 3 weeks ago

Ce serait encore pire avec les miens, je peux aider à tester par contre.

ic-dev21 commented 3 weeks ago

Pour les intéressés: https://github.com/dvd-dev/python-hilo/tree/blocking_calls

ic-dev21 commented 3 weeks ago

Ce serait encore pire avec les miens, je peux aider à tester par contre.

Quel type d'installation tu as? VM? Container? HAOS? Es-tu à l'aise un peu en command line? J'aurais quelque chose à te faire tester si tu le veux.

kayhos commented 3 weeks ago

Je roule HASS Container dans Docker, je peux rouler des commandes dans le EXEC du Docker ou dans le système hôte.

ic-dev21 commented 3 weeks ago

Je roule HASS Container dans Docker, je peux rouler des commandes dans le EXEC du Docker ou dans le système hôte.

Si tu es à l'aise de tester sur ton environnement normal (pas de risque de perte de données ou autre, le pire qui va arriver c'est que ta connexion à Hilo plante le temps que tu revert).

Dans docker exec:

pip uninstall python-hilo

Ensuite:

pip install git+https://github.com/dvd-dev/python-hilo.git@blocking_call2#egg=python-hilo

Si après tu roules

pip show python-hilo

Tu devrais voir, si l'installation a bien fonctionné:

image

Si oui, restart ton container et check tes logs, théoriquement il ne devrait rester que les blocking calls qui viennent de sensor.py

Pour revert:

Dans docker exec:

pip uninstall python-hilo
pip install python-hilo

Restart ton container.

Merci d'avance si tu as le temps!

kayhos commented 3 weeks ago

Résultats

minis:/config# pip uninstall python-hilo
Found existing installation: python-hilo 2024.4.1
Uninstalling python-hilo-2024.4.1:
  Would remove:
    /usr/local/lib/python3.12/site-packages/pyhilo/*
    /usr/local/lib/python3.12/site-packages/python_hilo-2024.4.1.dist-info/*
Proceed (Y/n)? y

Next

minis:/config# pip install git+https://github.com/dvd-dev/python-hilo.git@blocking_call2#egg=python-hi                                                                                                         lo
Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/
Collecting python-hilo
  Cloning https://github.com/dvd-dev/python-hilo.git (to revision blocking_call2) to /tmp/pip-install-                                                                                                         9bxcr6zv/python-hilo_3e9e312e2f7940799fd1268742d3525b
  Running command git clone --filter=blob:none --quiet https://github.com/dvd-dev/python-hilo.git /tmp                                                                                                         /pip-install-9bxcr6zv/python-hilo_3e9e312e2f7940799fd1268742d3525b
  Running command git checkout -b blocking_call2 --track origin/blocking_call2
  branch 'blocking_call2' set up to track 'origin/blocking_call2'.
  Switched to a new branch 'blocking_call2'
  Resolved https://github.com/dvd-dev/python-hilo.git to commit 10edc1f18f6492cf032d8e8f60f8ff82afb096                                                                                                         6d
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: aiohttp>=3.8.0 in /usr/local/lib/python3.12/site-packages (from python-hilo) (3.9.5)
Requirement already satisfied: aiosignal>=1.2.0 in /usr/local/lib/python3.12/site-packages (from python-hilo) (1.3.1)
Requirement already satisfied: async-timeout>=4.0.0 in /usr/local/lib/python3.12/site-packages (from python-hilo) (4.                                                                                          0.3)
Requirement already satisfied: attrs>=21.2.0 in /usr/local/lib/python3.12/site-packages (from python-hilo) (23.2.0)
Requirement already satisfied: backoff>=1.11.1 in /usr/local/lib/python3.12/site-packages (from python-hilo) (2.2.1)
Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/site-packages (from python-hilo) (                                                                                          2.9.0.post0)
Requirement already satisfied: ruyaml>=0.91.0 in /usr/local/lib/python3.12/site-packages (from python-hilo) (0.91.0)
Requirement already satisfied: voluptuous>=0.13.1 in /usr/local/lib/python3.12/site-packages (from python-hilo) (0.13                                                                                          .1)
Requirement already satisfied: websockets<12.0,>=8.1 in /usr/local/lib/python3.12/site-packages (from python-hilo) (1                                                                                          1.0.3)
Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.12/site-packages (from aiohttp>=3.8.0->pyt                                                                                          hon-hilo) (1.4.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.12/site-packages (from aiohttp>=3.8.0->p                                                                                          ython-hilo) (6.0.5)
Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.12/site-packages (from aiohttp>=3.8.0->python                                                                                          -hilo) (1.9.4)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/site-packages (from python-dateutil>=2.8.2->pyth                                                                                          on-hilo) (1.16.0)
Requirement already satisfied: distro>=1.3.0 in /usr/local/lib/python3.12/site-packages (from ruyaml>=0.91.0->python-                                                                                          hilo) (1.9.0)
Requirement already satisfied: setuptools>=39.0 in /usr/local/lib/python3.12/site-packages (from ruyaml>=0.91.0->pyth                                                                                          on-hilo) (69.2.0)
Requirement already satisfied: idna>=2.0 in /usr/local/lib/python3.12/site-packages (from yarl<2.0,>=1.0->aiohttp>=3.                                                                                          8.0->python-hilo) (3.7)
Building wheels for collected packages: python-hilo
  Building wheel for python-hilo (pyproject.toml) ... done
  Created wheel for python-hilo: filename=python_hilo-2024.6.1-py3-none-any.whl size=27696 sha256=ad7b275bbf2c87ec16a                                                                                          d7678fb7ecf8b2817f9354ae0b8da51e0fc6875e7de02
  Stored in directory: /tmp/pip-ephem-wheel-cache-aqe49rbx/wheels/e3/2e/5c/bec4b6fca0d6db172de2e9e562ceadb8cf61446325                                                                                          a6f29478
Successfully built python-hilo
Installing collected packages: python-hilo
Successfully installed python-hilo-2024.6.1
minis:/config# pip show python-hilo
Name: python-hilo
Version: 2024.6.1
Summary: A Python3, async interface to the Hilo API
Home-page: https://github.com/dvd-dev/python-hilo
Author: David Vallee Delisle
Author-email: me@dvd.dev
License: MIT
Location: /usr/local/lib/python3.12/site-packages
Requires: aiohttp, aiosignal, async-timeout, attrs, backoff, python-dateutil, ruyaml, voluptuous, websockets
Required-by:

Après le restart du container, j'ai eut cet état dans HASS image

En essayant de rétablir le oauth avec Hilo, j'ai eut un timeout (pourrait ne pas être relié), voici les info dans le log

2024-06-07 22:26:40.970 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('hilo', '[REDACTED]'): 34937.543856285}
2024-06-07 22:27:41.030 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('hilo', '[REDACTED]'): 34937.543856285}
2024-06-07 22:27:56.094 WARNING (MainThread) [homeassistant.config_entries] Config entry '[REDACTED]' for hilo integration could not authenticate: Cannot connect to host connexion.hiloenergie.com:443 ssl:default [Network unreachable]
2024-06-07 22:27:56.109 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.helpers.event. This is deprecated and will stop working in Home Assistant 2024.11, it should be updated to import functions used from event directly at custom_components/hacs/base.py, line 630: self.hass.helpers.event.async_track_time_interval(, please create a bug report at https://github.com/hacs/integration/issues
2024-06-07 22:30:15.284 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Timeout resolving OAuth token: 
2024-06-07 22:30:44.604 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 487, in get
    await hass.config_entries.flow.async_configure(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 379, in _async_configure
    raise UnknownFlow
homeassistant.data_entry_flow.UnknownFlow
ic-dev21 commented 3 weeks ago

Aux alentours des mêmes heures la connexion a l’air d’être tombé ici sur mon prod.

As-tu pu rétablir?

kayhos commented 3 weeks ago

Je confirme, la connectivité à été rétablie ce matin.

ic-dev21 commented 3 weeks ago

Je confirme, la connectivité à été rétablie ce matin.

Avec pyhilo 2024.6.1? Si oui good, je suis sur la bonne voie!

kayhos commented 3 weeks ago

En tout cas, c'est ce que ça dit dans le test que tu m'as fait faire hier (https://github.com/dvd-dev/hilo/issues/434#issuecomment-2155767148). Je n'ai pas fait de rollback.

ic-dev21 commented 3 weeks ago

En tout cas, c'est ce que ça dit dans le test que tu m'as fait faire hier (#434 (comment)). Je n'ai pas fait de rollback.

Awesome!

Des fois un sanity check comme ça ça aide pas mal! Merci!

Pour ceux qui pourraient lire ça et voudraient comprendre le pourquoi: Dans le passé les gens de Hilo et d'autres ont fait générer au custom_component des fichiers yaml, un qui contient notre token de login (hilo_state.yaml) et un avec tout notre historique de défi (hilo_eventhistory_state.yaml).

Ces deux fichiers-là sont très utiles, le premier, bah sans lui oublies ton login!

Le deuxième permet une mise en cache hard drive de notre historique de défi, ce qui fait qu'on ne poll pas la table au complet chez Hilo aux minutes comme on le faisait auparavant, ça réduit pas mal la jasette!

Ces deux opérations là étaient synchrones donc bloquait des cycles CPU.

Le tit bout que je viens d'éssayer c'est la portion login.

Va me manquer à gosser dans la portion historique de défi, peut-être en fds vu qu'il pleut!

ic-dev21 commented 3 weeks ago

Fix partiel via: https://github.com/dvd-dev/python-hilo/pull/196