sopelj / hass-ember-mug-component

Ember Mug Integration for Home Assistant
MIT License
111 stars 4 forks source link

Bluetooth Pairing Problems #30

Closed imhotep closed 1 year ago

imhotep commented 1 year ago

Description

Device would not pair through this component. Nor does it want to pair with bluetoothctl. I did run a firmware update when I first got the device. I am not sure if that's why it doesn't want to work anymore.

What I Did

Paired the mug with my mobile device and updated firmware to 394/4. My Hardware version is 10 Deleted/unpaired device from my mobile device. Put the device into pairing mode by holding the button below until the LED blinks blue. Ran the following

$ sudo service bluetooth stop
$ sudo service bluetooth start
$ bluetoothctl power on
Changing power on succeeded
$ bluetoothctl agent on
$ bluetoothctl trust FA:15:F2:XX:XX:XX
Changing FA:15:F2:XX:XX:XX trust succeeded
$ bluetoothctl pair FA:15:F2:XX:XX:XX
Attempting to pair with FA:15:F2:XX:XX:XX
[CHG] Device FA:15:F2:XX:XX:XX Connected: yes
Failed to pair: org.bluez.Error.ConnectionAttemptFailed
$ bluetoothctl pairable on
Changing pairable on succeeded
$ bluetoothctl discoverable on
Changing discoverable on succeeded
$ bluetoothctl pair FA:15:F2:XX:XX:XX
Attempting to pair with FA:15:F2:XX:XX:XX
[CHG] Device FA:15:F2:XX:XX:XX Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed 

Logs / Errors

I don't think it's this component's fault so not attaching any logs.

sopelj commented 1 year ago

Hi, thanks for the info! I assume you have an Ember Mug 2? As that's what I have and I have the same version numbers, so I think that means we have the same model and firmware. That means it should work.

That's strange that you can't get it to pair. What are you using for your Bluetooth Adapter? Is it one of the ones known to work with Home assistant? Other adapters should work too, but I think you need to have one that at least supports Bluetooth 4.2. Not certain though.

If you have an ESP32 laying around you you can try with a Bluetooth Proxy too as long as it's the "active" ones it should work.

Oh, also, "Failed to pair" can happen if it is already paired... So you may have succeeded and it just won't re-pair. You can check with bluetoothctl info FA:15:F2:XX:XX:XX.

imhotep commented 1 year ago

Yes, I have the Ember Mug 2. I have no idea why it's not pairing

I tried with two other linux devices: a raspberry pi 400 and my desktop running ubuntu and these would not even see the mug when I set scan on

My home assistant instance is an intel nuc 10th gen so it supports bluetooth 5.

I will try with an esp32.

I think it's paired before but it never succeeds in connecting, like something is blocking it. I am not clear on how pairing/connecting work. I am going to close this. I figured I'd ask if you had any tips for me or if my mug is just incompatible.

sopelj commented 1 year ago

@imhotep Oh OK. Yes, the Ember Mug 2 definitely should work.

That's very strange... was it in pairing mode in those cases? The mug is very finicky and will only broadcast in pairing mode. Once paired it's pretty reliable though, but it still doesn't broadcast it unless you subscribe to it (that's what the integration does), but a simple scan won't see it.

OK, that's good. It should work in theory then as long as the adapter is not being used by anything else.

Hmm, OK. Well, if you have multiple devices trying to connect to it that can definitely happen. Maybe during tests another device was still paired to it. You can always try resetting it too (hold down the button until it goes blue, yellow, and then red and release), setting it up again with you phone and then un-pairing it from the phone and trying again using it with Home Assistant.

Don't hesitate if you have questions. Your mug should work. But Bluetooth can be finicky sometimes.

AeliusSaionji commented 1 year ago

I had trouble with mine, but I eventually wrangled it.

It seems as though it's simply not discoverable unless the ember app itself is trying to connect to it. There I'm guessing there's some backchannel wakeup signal sent by the app.

What eventually worked required using the app to request device setup (no login required), ignore the pairing request on phone, swoop in and pair with bluetoothctl. I also did trust for good measure.

Your README instructions suggest that the app needs to have spoken to the mug at least once to initialize it, but I would further add that there may be a time sensitive component. Clear the app's data to start the pairing process again while near your home assistant BT device, and attempt to pair to home assistant as soon as possible.

imhotep commented 1 year ago

@AeliusSaionji it took a few minutes but I got it working following your hints! Thank you so much for sharing! I am using the iOS app as the Android app never really worked for me (it seems like both apps are crap according to reviews):

I never got it to work following the instructions in the README.md and I tried with two different mugs. Speaking of which, does the integration work with 2+ mugs? It seems like the bluetooth adapter can only connect to one mug at at time.

@sopelj I'd definitely update the README.md with these instructions in case the common ones don't work.