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

The Switchmate integration and Bluetooth integration interference problem #76839

Closed
jluo98 opened this issue Aug 16, 2022 · 5 comments · Fixed by #76945
Closed

The Switchmate integration and Bluetooth integration interference problem #76839

jluo98 opened this issue Aug 16, 2022 · 5 comments · Fixed by #76945

Comments

@jluo98
Copy link

jluo98 commented Aug 16, 2022

The problem

The Switchmate integration is unable to connect to switches on startup if the Bluetooth integration is enabled.

The issue can be resolved by doing the following steps:

  • Disable the Bluetooth integration
  • Attempt re-connection to the Switchmate switch (e.g. Calling the homeassistant.update_entity service)
  • The switch becomes available
  • Re-enable the Bluetooth integration if needed by other components, which does not cause further issue

What version of Home Assistant Core has the issue?

core-2022.8.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Switchmate

Link to integration documentation on our website

https://www.home-assistant.io/integrations/switchmate/

Diagnostics information

No response

Example YAML snippet

switch:
  - platform: switchmate
    name: "snap_on_switch_1"
    mac: "XX:XX:XX:XX:XX:XX"

Anything in the logs that might be useful for us?

2022-08-15 23:14:35.374 ERROR (MainThread) [switchmate] Failed to connect to Switchmate
2022-08-15 23:14:36.147 ERROR (MainThread) [switchmate] Failed to connect to Switchmate
2022-08-15 23:14:36.150 ERROR (MainThread) [switchmate] Cannot communicate with Switchmate

Additional information

No response

@probot-home-assistant
Copy link

switchmate documentation
switchmate source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @Danielhiversen, @qiz-li, mind taking a look at this issue as it has been labeled with an integration (switchmate) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@qiz-li
Copy link

qiz-li commented Aug 16, 2022

Thanks @jluo98. Can confirm this is an issue. Unfortunately, it looks like there is a conflict between the scanning of the Bluetooth integration and Switchmate? Tagging @bdraco here, who might be able to help us further.

Failed to connect to Switchmate
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/switchmate/__init__.py", line 35, in _connect
    await self._device.connect()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 107, in connect
    device = await BleakScannerBlueZDBus.find_device_by_address(
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 221, in find_device_by_address
    return await cls.find_device_by_filter(
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 250, in find_device_by_filter
    async with cls(detection_callback=apply_filter, **kwargs):
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/scanner.py", line 96, in __aenter__
    await self.start()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 137, in start
    self._stop = await manager.active_scan(
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 405, in active_scan
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress

@bdraco
Copy link
Member

bdraco commented Aug 16, 2022

Is the bluetooth stick a realtek chipset?

@jluo98
Copy link
Author

jluo98 commented Aug 16, 2022

Is the bluetooth stick a realtek chipset?

Mine is a Broadcom chip inside the RPi 4 Model B.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants