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

Switchmates only work when bluetooth disabled #77813

Closed
MReschenberg opened this issue Sep 5, 2022 · 10 comments
Closed

Switchmates only work when bluetooth disabled #77813

MReschenberg opened this issue Sep 5, 2022 · 10 comments

Comments

@MReschenberg
Copy link

MReschenberg commented Sep 5, 2022

The problem

I have five Switchmates (original) linked to Home Assistant via the Switchmate integration. When the HA Bluetooth integration is on, all five devices are shown as inactive and unreachable. This issue persists across restarts, even if I restart the host device -- which is a Raspberry Pi 3B+ in my case.

If I disable the HA Bluetooth integration and restart HA, all five switches are immediately located and work.
I saw issue #76839 was recently addressed, and I hoped it would fix this problem, but I'm running the following and still have this problem:

Home Assistant 2022.8.7 
Supervisor 2022.08.5 
Operating System 8.5 
Frontend 20220802.0 - latest 

If I enable homeassistant.components.switch.switchmate: debug under Logger, I don't get any abnormal log info. I get a warning that the platform is taking over 10 seconds to load, but I also intermittently get that warning when the switches work. Please let me know if there's another way to get logs and I'll dig them up :)

What version of Home Assistant Core has the issue?

2022.8.7

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

- platform: switchmate
  mac: "xx:xx:...:xx"
  name: "Hallway Overheads"

Anything in the logs that might be useful for us?

No response

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)

@jluo98
Copy link

jluo98 commented Sep 6, 2022

According to the beta release notes, the fix should be implemented with the release of 2022.9. See Full Changelog for Home Assistant Core 2022.9 (Look for #76945).

@MReschenberg
Copy link
Author

oh awesome, thanks. I thought the merge date meant it was already in HA (released). I'll close this and re-open if the issue persists after I'm on 2022.9 :)

@Scags104
Copy link

Scags104 commented Sep 7, 2022

i think this needs to be reopened. This continues to stop working after Bluetooth is configured and rebooted on 2022.9.0

@MReschenberg
Copy link
Author

This issue is resolved for me in 2022.9.0 -- I can use my switchamtes and my other bluetooth devices that were previously running through the HA bluetooth integration (🎉) since I can't reproduce, @Scags104 it might be best if you file a new issue with your config

@huzecong
Copy link

huzecong commented Sep 7, 2022

To echo @Scags104, my Switchmate entities have also stopped working after the update. What's worse is previously I could get them to work by disabling the Bluetooth integration, but now even that's not working. I'm seeing the following in my logs:

Logger: homeassistant.helpers.frame
Source: helpers/frame.py:77
First occurred: 4:45:56 PM (1 occurrences)
Last logged: 4:45:56 PM

Detected integration that attempted to call BleakClient with an address instead of a BLEDevice. Please report issue for switchmate using this method at homeassistant/components/switchmate/switch.py, line 70: await self._device.update()

and then

Logger: switchmate
Source: components/switchmate/switch.py:70
First occurred: 4:45:56 PM (6 occurrences)
Last logged: 4:45:56 PM

Cannot communicate with Switchmate

Here's my Home Assistant versions:

Home Assistant 2022.9.0
Supervisor 2022.08.5
Operating System 8.5
Frontend 20220907.0 - latest

Hope this helps.

@huzecong
Copy link

I figured this out, it's a bit funny actually. I had the MAC address written in lowercase in my config, after switching to uppercase, it worked. It's a bit cumbersome because Home Assistant will recognize them as new entities, so I had to delete the old ones and reconfigure them to take the same entity IDs.

The reason I think this is happening is that 2022.09.0 started using bleak for bluetooth, and required integrations to provide a BLEDevice object for connections. However, the switchmate integration still used MAC addresses directly (which is why I saw that warning), so the bluetooth integration does a translation step via BluetoothManager. async_ble_device_from_address, which basically just looks up the address (as string) from a dictionary. Now, it seems like the raw MAC addresses are all uppercase, and there's no string transformation performed during the lookup, so lowercase addresses can't be looked up.

I consider this to be kind of a bug in the bluetooth integration. Hope it could be fixed in the upcoming updates.

@jluo98
Copy link

jluo98 commented Sep 10, 2022

I figured this out, it's a bit funny actually. I had the MAC address written in lowercase in my config, after switching to uppercase, it worked. It's a bit cumbersome because Home Assistant will recognize them as new entities, so I had to delete the old ones and reconfigure them to take the same entity IDs.

The reason I think this is happening is that 2022.09.0 started using bleak for bluetooth, and required integrations to provide a BLEDevice object for connections. However, the switchmate integration still used MAC addresses directly (which is why I saw that warning), so the bluetooth integration does a translation step via BluetoothManager. async_ble_device_from_address, which basically just looks up the address (as string) from a dictionary. Now, it seems like the raw MAC addresses are all uppercase, and there's no string transformation performed during the lookup, so lowercase addresses can't be looked up.

I consider this to be kind of a bug in the bluetooth integration. Hope it could be fixed in the upcoming updates.

Thanks for sharing this info! That explains why @MReschenberg said their integration was working perfectly. Probably needs to file an issue for the Bluetooth integration instead. I'll quote you on the issue I submitted for switchmate. Nonetheless, it's still the best to update the integration to use the new BLEDevice instead of passing the address.

@Scags104
Copy link

I figured this out, it's a bit funny actually. I had the MAC address written in lowercase in my config, after switching to uppercase, it worked. It's a bit cumbersome because Home Assistant will recognize them as new entities, so I had to delete the old ones and reconfigure them to take the same entity IDs.

The reason I think this is happening is that 2022.09.0 started using bleak for bluetooth, and required integrations to provide a BLEDevice object for connections. However, the switchmate integration still used MAC addresses directly (which is why I saw that warning), so the bluetooth integration does a translation step via BluetoothManager. async_ble_device_from_address, which basically just looks up the address (as string) from a dictionary. Now, it seems like the raw MAC addresses are all uppercase, and there's no string transformation performed during the lookup, so lowercase addresses can't be looked up.

I consider this to be kind of a bug in the bluetooth integration. Hope it could be fixed in the upcoming updates.

Just want to confirm. this simple fix did the trick. Thank you for figuring that out!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants