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

switchbot_cloud cannot connect while sending commands from an automation #116791

Open
johnypony3 opened this issue May 4, 2024 · 4 comments
Open

Comments

@johnypony3
Copy link

johnypony3 commented May 4, 2024

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 johnypony3 changed the title Python dependency Cora is missing, causing asyncio issues asyncio issues May 4, 2024
@johnypony3
Copy link
Author

Rolling back to 2024.4.4 fixes the issue.

@johnypony3
Copy link
Author

johnypony3 commented May 4, 2024

@home-assistant
Copy link

home-assistant bot commented May 4, 2024

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)

@bdraco bdraco changed the title asyncio issues switchbot_cloud cannot connect while sending commands from an automation May 4, 2024
@SeraphicRav
Copy link
Contributor

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?

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

No branches or pull requests

3 participants