lbbrhzn / ocpp

Home Assistant integration for electric vehicle chargers that support the Open Charge Point Protocol (OCPP).
MIT License
221 stars 68 forks source link

Detected blocking call to open inside the event loop by custom integration 'ocpp' #1199

Open Roos-AID opened 4 months ago

Roos-AID commented 4 months ago

Describe the bug Updated OCPP to 0.5.7 and to HA 2024.6.1 . Since then I get flood of warnings in log. The calling routine seems to be different in the different logs.

This is different than the previous reported flood that was fixed with 0.5.7

To Reproduce Update HA and OCPP to latest versions and check the HA log

Wallbox Pulsar Plus with Firmware: 6.4.14

Expected behavior No flood of warning errors

Different logs below (initial log at end)

After disconnecting the car and restarting HA once more Logger: homeassistant.util.loop Bron: util/loop.py:84 Eerst voorgekomen: 11:00:00 (2 gebeurtenissen) Laatst gelogd: 11:00:00

Detected blocking call to open inside the event loop by custom integration 'ocpp' at custom_components/ocpp/api.py, line 1005: await self.hass.async_create_task(super()._handle_call(msg)) (offender: /usr/local/lib/python3.12/site-packages/ocpp/messages.py, line 164: with open(path, "r", encoding="utf-8-sig") as f:), please create a bug report at https://github.com/lbbrhzn/ocpp/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/local/lib/python3.12/site-packages/ocpp/charge_point.py", line 238, in start await self.route_message(message) File "/usr/local/lib/python3.12/site-packages/ocpp/charge_point.py", line 261, in route_message await self._handle_call(msg) File "/config/custom_components/ocpp/api.py", line 1005, in _handle_call await self.hass.async_create_task(super()._handle_call(msg))

Initial log when the car was connected and HA was started with new versions of HA and OCPP Logger: homeassistant.util.loop Bron: util/loop.py:84 Eerst voorgekomen: 09:46:49 (764 gebeurtenissen) Laatst gelogd: 09:48:52

Detected blocking call to open inside the event loop by custom integration 'ocpp' at custom_components/ocpp/api.py, line 767: resp = await self.call(req) (offender: /usr/local/lib/python3.12/site-packages/ocpp/messages.py, line 164: with open(path, "r", encoding="utf-8-sig") as f:), please create a bug report at https://github.com/lbbrhzn/ocpp/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 "/config/custom_components/ocpp/switch.py", line 125, in async_turn_on self._state = await self.central_system.set_charger_state( File "/config/custom_components/ocpp/api.py", line 310, in set_charger_state resp = await self.charge_points[cp_id].start_transaction() File "/config/custom_components/ocpp/api.py", line 767, in start_transaction resp = await self.call(req) Detected blocking call to open inside the event loop by custom integration 'ocpp' at custom_components/ocpp/api.py, line 1005: await self.hass.async_create_task(super()._handle_call(msg)) (offender: /usr/local/lib/python3.12/site-packages/ocpp/messages.py, line 164: with open(path, "r", encoding="utf-8-sig") as f:), please create a bug report at https://github.com/lbbrhzn/ocpp/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/local/lib/python3.12/site-packages/ocpp/charge_point.py", line 238, in start await self.route_message(message) File "/usr/local/lib/python3.12/site-packages/ocpp/charge_point.py", line 261, in route_message await self._handle_call(msg) File "/config/custom_components/ocpp/api.py", line 1005, in _handle_call await self.hass.async_create_task(super()._handle_call(msg)) Detected blocking call to open inside the event loop by custom integration 'ocpp' at custom_components/ocpp/api.py, line 704: resp = await self.call(req) (offender: /usr/local/lib/python3.12/site-packages/ocpp/messages.py, line 164: with open(path, "r", encoding="utf-8-sig") as f:), please create a bug report at https://github.com/lbbrhzn/ocpp/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/components/number/init.py", line 121, in async_set_value await entity.async_set_native_value(native_value) File "/config/custom_components/ocpp/number.py", line 129, in async_set_native_value resp = await self.central_system.set_max_charge_rate_amps( File "/config/custom_components/ocpp/api.py", line 298, in set_max_charge_rate_amps return await self.charge_points[cp_id].set_charge_rate(limit_amps=value) File "/config/custom_components/ocpp/api.py", line 704, in set_charge_rate resp = await self.call(req) Detected blocking call to open inside the event loop by custom integration 'ocpp' at custom_components/ocpp/api.py, line 787: resp = await self.call(req) (offender: /usr/local/lib/python3.12/site-packages/ocpp/messages.py, line 164: with open(path, "r", encoding="utf-8-sig") as f:), please create a bug report at https://github.com/lbbrhzn/ocpp/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/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/websocket_api/http.py", line 54, in get return await WebSocketHandler(request.app[KEY_HASS], request).async_handle() File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 438, in async_handle async_handle_str(command_msg_data) File "/usr/src/homeassistant/homeassistant/components/websocket_api/connection.py", line 229, in async_handle handler(self.hass, self, schema(msg)) File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 46, in schedule_handler hass.async_create_background_task( File "/usr/src/homeassistant/homeassistant/core.py", line 860, in async_create_background_task task = create_eagertask(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/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service response = await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call response_data = await coro File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service return await target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 977, in entity_service_call single_response = await _handle_entity_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1041, in _handle_entity_call task = hass.async_run_hass_job(job) File "/usr/src/homeassistant/homeassistant/core.py", line 939, in async_run_hass_job return self._async_add_hass_job(hassjob, args, background=background) File "/usr/src/homeassistant/homeassistant/core.py", line 748, in _async_add_hass_job task = create_eagertask( 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/components/button/init.py", line 134, in _async_press_action await self.async_press() File "/config/custom_components/ev_smart_charging/button.py", line 62, in async_press await self.coordinator.turn_off_charging() File "/config/custom_components/ev_smart_charging/coordinator.py", line 419, in turn_off_charging await self.turn_on_charging(False) File "/config/custom_components/ev_smart_charging/coordinator.py", line 411, in turn_on_charging await self.hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2734, in async_call self._hass.async_create_task_internal( File "/usr/src/homeassistant/homeassistant/core.py", line 828, in async_create_task_internal task = create_eagertask(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/core.py", line 2761, in _run_service_call_catch_exceptions await coro_or_task File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service return await target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 977, in entity_service_call single_response = await _handle_entity_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1041, in _handle_entity_call task = hass.async_run_hass_job(job) File "/usr/src/homeassistant/homeassistant/core.py", line 939, in async_run_hass_job return self._async_add_hass_job(hassjob, args, background=background) File "/usr/src/homeassistant/homeassistant/core.py", line 748, in _async_add_hass_job task = create_eagertask( 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/ocpp/switch.py", line 139, in async_turn_off resp = await self.central_system.set_charger_state( File "/config/custom_components/ocpp/api.py", line 312, in set_charger_state resp = await self.charge_points[cp_id].stop_transaction() File "/config/custom_components/ocpp/api.py", line 787, in stop_transaction resp = await self.call(req) Detected blocking call to open inside the event loop by custom integration 'ocpp' at custom_components/ocpp/api.py, line 787: resp = await self.call(req) (offender: /usr/local/lib/python3.12/site-packages/ocpp/messages.py, line 164: with open(path, "r", encoding="utf-8-sig") as f:), please create a bug report at https://github.com/lbbrhzn/ocpp/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 "/config/custom_components/ocpp/switch.py", line 139, in async_turn_off resp = await self.central_system.set_charger_state( File "/config/custom_components/ocpp/api.py", line 312, in set_charger_state resp = await self.charge_points[cp_id].stop_transaction() File "/config/custom_components/ocpp/api.py", line 787, in stop_transaction resp = await self.call(req)

mariusves commented 4 months ago

Can confirm this with OCPP 0.5.7 and HA 2024.6.1. Charger is an EVbox Elvi. Worked stable beforehand. OCPP loses connection to the charger (or vise versa) every couple of minutes.

drc38 commented 4 months ago

@lbbrhzn any ideas on how these calls can run outside the event loop or amended to run within it without causing errors?

bec-aus commented 3 months ago

I have this too with an MG Smartcharger (which shows up as a Star Charge). It is updated to as newer firmware as I can find (V1.1.2.7.6b107.1_C_003) and has never really created a stable connection to HA. I was trouble shooting it when I found this.

drc38 commented 3 months ago

This may need to be fixed upstream see https://github.com/mobilityhouse/ocpp/issues/647

github-actions[bot] commented 1 month ago

Stale issue message

drc38 commented 1 month ago

Still waiting on upstream merge