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
Actually check the paired state instead of assuming it for bluetooth connection sensor #2738
Conversation
I think a better way instead of adding another condition is to just call |
ok now i think it should be good 🤞 |
Unfortunately, I don't think it is. It works for me, but Android's Assuming my interpretation of your comments in the issue is correct, suggestion: for (btDev in btConnectedDevices) {
if (!allowDuplicates && devices.any { it.address == btDev.address }) continue
val name = btDev.name ?: btDev.address
val device = BluetoothDevice(
btDev.address,
name,
btDev.bondState == android.bluetooth.BluetoothDevice.BOND_BONDED,
isConnected(btDev)
)
if (!devices.contains(device)) devices.add(device)
} |
it actually did show up as connected when I tested the latest change. In my setup the attributes have always been correct in each of the changes, which makes the testing part difficult lol. Even when I test your provided code just now I see no changes. My Mi band is actually not a paired device (not paired to the OS but paired to its own app) so it should only show up as
I always took it as allow duplicates was meant more to hide the non-paired devices. At least thats how I initially read it. With that said IMO the device address is really the only thing that counts. |
In that case I didn't understand your comments, sorry. For connected, not paired devices there should indeed be no changes 🙈
No it was added in #2591 to stop the settings from crashing due to device addresses being included twice in the list, while still allowing this sensor to get a list with a device with the same address showing up in both the paired connected and not paired connected lists. As you can see it doesn't do anything for non-paired devices. Considering the issue this PR solves and the confusion it creates, looking back at it I think it is no longer necessary? The app will now always check paired + connected status irregardless of the source -> duplicates should never happen. |
one of those things were code wise it doesnt look right, until you look at the end result and realize why it was like that 😅 So I guess I should close the PR then? |
No the PR is still good to have! 'it' was referring to Keep the changes from the first commit, remove android/common/src/main/java/io/homeassistant/companion/android/common/bluetooth/BluetoothUtils.kt Line 36 in 90a9a27
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience @dshokouhi ❤️
Tested and resolves the issue
Thanks for your help in testing and code suggestions 😃 |
Summary
Fixes: #2736 by actually checking the bonded state. I am also suppressing the lint message as its not valid in our use case and makes the page look like it won't compile. The main app already requests the proper permission and its not necessary for the Wear app.
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes