sopelj / hass-ember-mug-component

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

Bluetooth proxies are not working #15

Closed bakerboy908 closed 1 year ago

bakerboy908 commented 2 years ago

Im unsure if this is an issue with the ESP proxy or with this integration

Here is the error im getting in home assistant (C3:DF:EA:CC:38:40) - C3:DF:EA:CC:38:40 -> esp32-bluetooth-proxy-c99384: Failed to connect: No backend with an available connection slot that can reach address C3:DF:EA:CC:38:40 was found: The proxy/adapter is out of connection slots; Add additional proxies near this device Pairing is not available in ESPHome.

LCMilstein commented 1 year ago

UPDATE: I tried what I proposed below. I removed 1 of my proxies, so my setup is a single ESP32 with the BTProxy installed, and it's still the same issue. Pairing works and stays connected until the Ember goes to sleep/turns off at which point it's reported as "Unavailable" in the integration. Waking it/charging it does nothing. Putting it back in pairing mode works.

FYI, I'm experiencing the same thing as @sopelj above. I mentioned before that I have 2 bt proxies (esp32 devices) but they're added directly into HA using the BT Proxy page to flash them, and not going through ESPHome. So long as the mug is in pairing mode, it seems to work, but connection is lost after. I think I need 2 proxies to get coverage, but I'm going to disconnect 1 for troubleshooting and can report back.

sopelj commented 1 year ago

UPDATE: I tried what I proposed below. I removed 1 of my proxies, so my setup is a single ESP32 with the BTProxy installed, and it's still the same issue. Pairing works and stays connected until the Ember goes to sleep/turns off at which point it's reported as "Unavailable" in the integration. Waking it/charging it does nothing. Putting it back in pairing mode works.

FYI, I'm experiencing the same thing as @sopelj above. I mentioned before that I have 2 bt proxies (esp32 devices) but they're added directly into HA using the BT Proxy page to flash them, and not going through ESPHome. So long as the mug is in pairing mode, it seems to work, but connection is lost after. I think I need 2 proxies to get coverage, but I'm going to disconnect 1 for troubleshooting and can report back.

Thank you very much @LCMilstein for testing. Did you get any errors in your ESPHome logs or can it simply no longer detect it? Is your proxy up to date? They have been changing it a lot. What does your proxy config look like? Do you extent the base config or did you define it manually? If you did it manually perhaps souble check to ensure you have active: true in scan_parameters.

sopelj commented 1 year ago

I've been testing with my proxy for the past couple days. It seems to work pretty well. I created a beta 1 0.5.2 although I'm not sure if that made the difference. The mug stays connected as long as you are within range. However, if you do go out of range of your proxy it does look like you need to briefly put it back in pairing mode to be connected again. I'm not sure how this behaves with multiple proxies as I only have one spare ESP32 for the moment. If someone could test that would be much appreciated. I also changed the scan_parameters of the proxy that I found on a git issue that seems to help with disconnections, although, I'm not sure if it is required either.

esp32_ble_tracker:
 scan_parameters:
    interval: 450ms
    window: 160ms
    active: true
sopelj commented 1 year ago

Ok, I've done a lot of testing with the single Proxy I have, but as far as I can tell, there doesn't seem to be anything I can do from the point of the integration.

The ESPHome Proxy seems to automatically disconnect from any device that hasn't sent out a broadcast even if it is still actively connected and sending signals. This is probably just to ensure the three active spots are freed up. Sadly, the mug only does this in pairing mode.

Perhaps they will add an option to prevent this in future for active devices, but for now, the only options for proxies seem to be: A. Briefly enter pairing mode to reconnect when you want it to connect. B. Leave the device in pairing mode all the time and it will stay connected.

I will keep looking around for other options too. Maybe we can force it somehow. However, for now I will put this in the readme as current way to use it with proxies.

If anyone has any ideas please let me know though. I do want to make this work better.

sopelj commented 1 year ago

Actually, it looks like ESPHome 2023.4 and Home Assistant 2023.4 added support for pairing with Bluetooth Proxies! So this might be fixed. It seems to be able to not only pair, but reconnect. At least with ESPHome 2023.2 and the latest beta of Home Assistant 2023.4. It has been connected all day, but I'll wait until tomorrow at least to see if it stays connected, before getting too excited. But if someone else has one or more proxies and can confirm or deny that would be nice too. I only have one, so I can't test interferance.

sopelj commented 1 year ago

It really seems to be working! Disconnect/reconnect works too. So, so far, it looks like this is resolved. At least with one Proxy as I can't test two right now. I'll leave this issue open for a couple days for possible feedback and then I'll close it if nothing comes up.

MrKuenning commented 1 year ago

Excited to try.

sopelj commented 1 year ago

Excited to try.

If it works for you please let me know. Still going strong here after three days. Despite restarts and everything.

austin202220 commented 1 year ago

So I have multiple proxies and lots of BT devices, let me do some testing. I just did a fresh install and added my mug via a proxy node running esphome 2023.3.2, sensor values look good but the mug stays in pairing mode with blue flashing light. Not really a problem, I just stopped the pairing mode by pushing the button on the bottom of the mug. I tested walking to the other side of my house next to a different proxy node and the mug goes unavailable.

I might not have given it enough time, I think the proxies only scan on a set time interval and I may not have waited long enough. When I came back to the original node it wasn't picking up the mug either so i put it back to blue flash pairing mode and it picked up right away.

I retried the 2nd proxy node and same thing, wasn't picking up the mug. Next I switched the mug to pairing mode and then my second proxy node picks it up right away. So I can definitely confirm it is communicating through proxies. Not just need to do some testing of switching between proxies and see if it can do it without changing the mug back to pairing mode each time.

I'll keep testing some more scenarios

sopelj commented 1 year ago

So I have multiple proxies and lots of BT devices, let me do some testing. I just did a fresh install and added my mug via a proxy node running esphome 2023.3.2, sensor values look good but the mug stays in pairing mode with blue flashing light. Not really a problem, I just stopped the pairing mode by pushing the button on the bottom of the mug. I tested walking to the other side of my house next to a different proxy node and the mug goes unavailable.

I might not have given it enough time, I think the proxies only scan on a set time interval and I may not have waited long enough. When I came back to the original node it wasn't picking up the mug either so i put it back to blue flash pairing mode and it picked up right away.

I retried the 2nd proxy node and same thing, wasn't picking up the mug. Next I switched the mug to pairing mode and then my second proxy node picks it up right away. So I can definitely confirm it is communicating through proxies. Not just need to do some testing of switching between proxies and see if it can do it without changing the mug back to pairing mode each time.

I'll keep testing some more scenarios

Thank you very much for testing @austin202220. That's good you're on ESPHome 2023.2, but are you also on the beta of Home Assistant 2023.4? The pairing is partially implemented in the bluetooth integration of Home Assistant so you need that update too. The public release is tomorrow if you don't want to try the beta.

MrKuenning commented 1 year ago

So far so good, after getting HASS 2023.4 my mug has stayed connected.

2023-04-07 09_05_13-Overview – Home Assistant

I am not on ESPHome 2023.4 as it has not dropped yet.

Also noticed the cup sitting on and draining the battery with nothing in it. I just powered it off by pressing the button. Will continue to experiment.

sopelj commented 1 year ago

That's great! ESPHome 2023.2 is the latest. 2023.4 is for Home Assistant. I'm not sure they follow the same versioning scheme.

Ok, was your mug heating? Because I have noticed when the mug is empty, but wet sometimes it will heat up to dry itself off. Either because it's programmed to or because it thinks there is still water because it is humid. That is not related to the integration though, if that's the case though.

sopelj commented 1 year ago

Ok, so with the release of Home Assistant 2023.4 Bluetooth proxies should work without issues. I've been using it for over a week, and it reconnects without a problem. I've created the release 0.6.0 which requires that version, if you install it you should be fine.

As such, I'm going to close this issue as it seems to be resolved. If people have other issues with Bluetooth proxies, please create an issue for the specific issue, and I'll be happy to help resolve it.

Thanks for your help!

MrKuenning commented 1 year ago

Thank you so much for your hard work and dedication to making this issue work for those of us that only have proxies.