home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.66k stars 28.83k forks source link

switchbot_cloud cannot connect while sending commands from an automation #116791

Open johnypony3 opened 1 month ago

johnypony3 commented 1 month ago

The problem

Issue resolved with:

pip install Cora

What version of Home Assistant Core has the issue?

core-2024.5.1

What was the last working version of Home Assistant Core?

core-2024.4.4

What type of installation are you running?

Home Assistant Container

Integration causing the issue

None

Link to integration documentation on our website

None

Diagnostics information

2024-05-04 08:40:51.465 ERROR (MainThread) [homeassistant.components.script.1712581780298] Ashley’s Light Fader: If at step 5: Error executing script. Unexpected error for call_service at pos 1: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 736, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/light/init.py", line 627, in async_handle_light_on_service await light.async_turn_on(filter_turn_on_params(light, params)) File "/config/custom_components/lightener/light.py", line 256, in async_turn_on await self.hass.services.async_call( File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/light/init.py", line 627, in async_handle_light_on_service await light.async_turn_on(filter_turn_on_params(light, params)) File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switch_as_x/entity.py", line 152, in async_turn_on await self.hass.services.async_call( File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switchbot_cloud/switch.py", line 39, in async_turn_on await self.send_command(CommonCommands.ON) File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switchbot_cloud/entity.py", line 45, in send_command await self._api.send_command( File "/usr/local/lib/python3.12/site-packages/switchbot_api/init.py", line 291, in send_command await self._request(f"devices/{device_id}/commands", callback="post", json=json) File "/usr/local/lib/python3.12/site-packages/switchbot_api/init.py", line 217, in _request raise CannotConnect() switchbot_api.CannotConnect 2024-05-04 08:40:51.781 ERROR (MainThread) [homeassistant.components.script.1712581780298] Ashley’s Light Fader: Error executing script. Unexpected error for if at pos 5: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 1043, in _async_if_step await self._async_run_script(if_data["if_then"]) File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 1210, in _async_run_script result = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 1731, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 451, in async_run await self._async_step(log_exceptions=False) File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 503, in _async_step self._handle_exception( File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 533, in _handle_exception raise exception File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 736, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/light/init.py", line 627, in async_handle_light_on_service await light.async_turn_on(filter_turn_on_params(light, params)) File "/config/custom_components/lightener/light.py", line 256, in async_turn_on await self.hass.services.async_call( File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/light/init.py", line 627, in async_handle_light_on_service await light.async_turn_on(filter_turn_on_params(light, params)) File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switch_as_x/entity.py", line 152, in async_turn_on await self.hass.services.async_call( File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switchbot_cloud/switch.py", line 39, in async_turn_on await self.send_command(CommonCommands.ON) File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switchbot_cloud/entity.py", line 45, in send_command await self._api.send_command( File "/usr/local/lib/python3.12/site-packages/switchbot_api/init.py", line 291, in send_command await self._request(f"devices/{device_id}/commands", callback="post", json=json) File "/usr/local/lib/python3.12/site-packages/switchbot_api/init.py", line 217, in _request raise CannotConnect() switchbot_api.CannotConnect 2024-05-04 08:40:51.878 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Parallel action at step 1: parallel 1: Error executing script. Unexpected error for call_service at pos 1: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 736, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/script/init.py", line 654, in _service_handler response = await self._async_start_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/script/init.py", line 612, in _async_start_run script_result = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/script/init.py", line 643, in _async_run return await self.script.async_run(script_vars, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 1731, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 451, in async_run await self._async_step(log_exceptions=False) File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 503, in _async_step self._handle_exception( File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 533, in _handle_exception raise exception File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 1043, in _async_if_step await self._async_run_script(if_data["if_then"]) File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 1210, in _async_run_script result = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 1731, in async_run return await asyncio.shield(create_eager_task(run.async_run())) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 451, in async_run await self._async_step(log_exceptions=False) File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 503, in _async_step self._handle_exception( File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 533, in _handle_exception raise exception File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 501, in _async_step await getattr(self, handler)() File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 736, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/script.py", line 699, in _async_run_long_action return await long_task ^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/light/init.py", line 627, in async_handle_light_on_service await light.async_turn_on(filter_turn_on_params(light, params)) File "/config/custom_components/lightener/light.py", line 256, in async_turn_on await self.hass.services.async_call( File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/light/init.py", line 627, in async_handle_light_on_service await light.async_turn_on(filter_turn_on_params(light, params)) File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switch_as_x/entity.py", line 152, in async_turn_on await self.hass.services.async_call( File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2738, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/core.py", line 2779, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 975, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/helpers/service.py", line 1047, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switchbot_cloud/switch.py", line 39, in async_turn_on await self.send_command(CommonCommands.ON) File "/usr/local/lib/python3.12/site-packages/homeassistant/components/switchbot_cloud/entity.py", line 45, in send_command await self._api.send_command( File "/usr/local/lib/python3.12/site-packages/switchbot_api/init.py", line 291, in send_command await self._request(f"devices/{device_id}/commands", callback="post", json=json) File "/usr/local/lib/python3.12/site-packages/switchbot_api/init.py", line 217, in _request raise CannotConnect() switchbot_api.CannotConnect

Example YAML snippet

parallel:
  - alias: Something
    service: something
  - alias: Something_Else
    service: something_else

Anything in the logs that might be useful for us?

No response

Additional information

I was able to reproduce the issue and the solution by recreating the container, observing the issue, executing the fix and observing resolved issue.

The issue is not resolved unfortunately.

johnypony3 commented 1 month ago

Rolling back to 2024.4.4 fixes the issue.

johnypony3 commented 1 month ago

I looked through some of the issues and I can see multiple duplicated issues:

is:issue is:open in:body await created:2024-05-04

Search filter:

is:issue is:open in:body await created:2024-05-04 
home-assistant[bot] commented 1 month ago

Hey there @seraphicrav, mind taking a look at this issue as it has been labeled with an integration (switchbot_cloud) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `switchbot_cloud` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign switchbot_cloud` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


switchbot_cloud documentation switchbot_cloud source (message by IssueLinks)

SeraphicRav commented 1 month ago

I tried with the container version with version 2024.5.2 with control from the dashboard or automation and did not meet any error.

@johnypony3 Can you please try updating to the latest version and tell me you can see any improvement?