-
Notifications
You must be signed in to change notification settings - Fork 8
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
BT Proxy extremely unreliable #75
Comments
Hi! Can you try v5.0.3? |
I experience the same behaviour with D1 Mini ESP32 bluetooth proxies. I will try out v5.0.3 and will report if the connection is more stable. |
I can relate to this issue as well so please tell me if you need any specific log or test done. My esp config:
|
In the meantime i tried to set up ble_client on the esp32 with:
I get this as error within the esp:
I also did reset the thermostat and double checked the pin. Second bluetooth thermostat from another brand works as intended with same config. |
Sure thing - I have also updated to v5.0.3 - no changes in behavior |
What scan interval did you configure in Home Assistant? I believe the thermostats disable their bluetooth radio if no command is sent after X minutes. For me the radio stays active about 1:30 minutes and the gets disabled for about 30 seconds, but for you it might be different. If you are familiar with Python could you try out the following two scripts on a machine that has an internal or external bluetooth adapter and that is close to the thermostat and tell us what the output is? You'd have to do This script should lead to disconnects: import asyncio
import logging
from bleak import BleakClient
MAC_ADDRESS = "00:1A:22:0C:E7:E3" # Replace with the MAC address you want to connect to
NOTIFY_UUID = "d0e8434d-cd29-0996-af41-6c90f4e0eb2a"
WRITE_UUID = "3fa4585a-ce4a-3bad-db4b-b8df8179ea09"
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(message)s")
class Client:
def __init__(self):
self._client = BleakClient(
MAC_ADDRESS, disconnected_callback=self._on_disconnect
)
self._is_connected = False
@property
def is_connected(self):
return self._is_connected
async def run(self):
while True:
while not self._client.is_connected:
try:
await self._client.connect()
self._is_connected = True
except Exception as e:
logging.error(e)
await asyncio.sleep(1)
await self._client.start_notify(NOTIFY_UUID, self._on_notify)
while self._client.is_connected:
pass
# await self._client.write_gatt_char(WRITE_UUID, bytearray([0x02]))
await asyncio.sleep(10)
def _on_disconnect(self, client: BleakClient):
self._is_connected = False
def _on_notify(self, sender: int, data: bytearray):
# log the received data in this format: Received: 0x00 0x01 0x02 ...
logging.debug(f"Received: {' '.join([f'0x{b:02x}' for b in data])}")
class Monitor:
def __init__(self, client: Client):
self._client = client
self._last_is_connected: bool | None = None
async def run(self):
while True:
if self._last_is_connected != self._client.is_connected:
self._last_is_connected = self._client.is_connected
logging.info(
f"Status changed: {'Connected' if self._last_is_connected else 'Disconnected'}"
)
await asyncio.sleep(1)
async def main():
client = Client()
monitor = Monitor(client)
await asyncio.gather(client.run(), monitor.run())
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
logging.info("KeyboardInterrupt") This should keep an active connection without any disconnects: import asyncio
import logging
from bleak import BleakClient
MAC_ADDRESS = "00:1A:22:0C:E7:E3" # Replace with the MAC address you want to connect to
NOTIFY_UUID = "d0e8434d-cd29-0996-af41-6c90f4e0eb2a"
WRITE_UUID = "3fa4585a-ce4a-3bad-db4b-b8df8179ea09"
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(message)s")
class Client:
def __init__(self):
self._client = BleakClient(
MAC_ADDRESS, disconnected_callback=self._on_disconnect
)
self._is_connected = False
@property
def is_connected(self):
return self._is_connected
async def run(self):
while True:
while not self._client.is_connected:
try:
await self._client.connect()
self._is_connected = True
except Exception as e:
logging.error(e)
await asyncio.sleep(1)
await self._client.start_notify(NOTIFY_UUID, self._on_notify)
while self._client.is_connected:
await self._client.write_gatt_char(WRITE_UUID, bytearray([0x02]))
await asyncio.sleep(10)
def _on_disconnect(self, client: BleakClient):
self._is_connected = False
def _on_notify(self, sender: int, data: bytearray):
# log the received data in this format: Received: 0x00 0x01 0x02 ...
logging.debug(f"Received: {' '.join([f'0x{b:02x}' for b in data])}")
class Monitor:
def __init__(self, client: Client):
self._client = client
self._last_is_connected: bool | None = None
async def run(self):
while True:
if self._last_is_connected != self._client.is_connected:
self._last_is_connected = self._client.is_connected
logging.info(
f"Status changed: {'Connected' if self._last_is_connected else 'Disconnected'}"
)
await asyncio.sleep(1)
async def main():
client = Client()
monitor = Monitor(client)
await asyncio.gather(client.run(), monitor.run())
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
logging.info("KeyboardInterrupt") |
@EuleMitKeule Thanks a lot for the code. All thermostats are configured with the standard 1 minute. Unfortunately I don't have a linux machine that is close enough to the thermostats. I will try to do this with my mac on sunday.
|
I can only guess, maybe the bluetooth proxies think they are connected and are trying to write to the thermostat even though the thermostat already turned off its radio? Once the changes are merged into |
The problem with the BLE proxies has existed for around 18 months. There is a workaround for using tasmota on the BLE proxies. https://github.com/Eroli/Tasmota/tree/master If you're interested, I'll write instructions here. Thanks to “Eroli” I now have some practice :-) |
Actually the BLE proxies work perfectly fine without any disconnects at all, you simply have to send a message to the thermostat more often (like every 10 seconds) for the thermostat to not shut down its radio. I have fixed this problem and tested it out successfully using esp32 bluetooth proxies over long periods of time. The updated integration will be part of the next release of the Home Assistant core. |
Thanks! Instructions would be awesome! :) Maybe you can put it as a new topic in the discussion section for better visibility? To be honest, ESP32-Setup and Usage comes too short inside the documentation. There is a lot of Information on the ESP32-topic spread over many tickets and could be mentioned in the readme. Its hard to determine relevant steps to get it working or even if there are any, especially if you are not a very experienced user. |
Of course an ESPhome solution is preferable but as long as it doesn't work well this is a route you can take. Besides, a solution where you force the thermostat to be active every 10 seconds isn't really a good solution. The thermostat batteries are used up 3 to 4 times faster. It makes little sense to keep a passive BLE unit permanently active. So this can at most be a workaround that doesn't solve the actual problem. A doctor would say that you have treated the symptom but not eliminated the cause. I'll put it more drastically. Of course you can cover a coffee stain on a tablecloth with a fruit bowl but the stain is still there. Triggering the thermostats a lot is more like putting a fruit bowl on a coffee stain. |
These thermostats unfortunately don't seem to broadcast their state, one has to connect first. As to why the connection is so unreliable with btproxys, it is a bit of a mystery to me, particularly those with old firmware, since those don't have pairing with pin. |
The new firmware with the 6 characters does not require any pairing. I can also confirm that, I use 18 EQ-3s. 11 Units have 6 character pins the other 4 character pins. Some time ago I reset all EQ-3 and only switched on BLE. I haven't done any pairing. I haven't used any apps on my smartphone since the Tasmota solution worked reliably. By the way, only the MAC is required. Pairing is only necessary for the smartphone app. I can connect and manipulate any EQ-3 unit with my Linux computer. I tested it with my laptop at the neighbor's doorstep and manipulated its units, it worked great. He was probably a bit warm that day :-) Entering the pairing code in the ESPhome code is completely pointless because it is not queried. It's the app that asks for it and not the thermostat's firmware. This is supposedly to prevent abuse by neighbors :-) It should be mentioned that the HA team has known about the problem for a long time. I am therefore not surprised that they are willing to adopt the solution with the timing even though it is known that this solution is a dead end. I'm just assuming that they have absolutely no desire to take care of a few heating nerds with EQ-3 units :-) They hope that the things will "die out" and that the problem will solve itself. |
lol I think you're misjudging me. I am very familiar with the way we work in open source projects and I am aware that the people behind the project sacrifice their free time for it. Every year I donate a not inconsiderable sum of money to various open source projects that I use myself in order to at least financially recognize the work behind them. It's possible that I get on someone's nerves with the way I talk, but problems aren't solved by talking about them every now and then, but rather by addressing the problem again and again. As a user, I am not a bit maker but an important link in the open source chain. Without information from users for whom these projects are, there is no improvement or progress. But it's not like I didn't understand your point. passt schon :-) |
Not my experience. The previous fw had fake pairing, the new one has real Bluetooth paring, but it looks like it has a bug where it will still take commands while pairing. A client that respects the standard can't communicate without pairing.
Not in the new fw
Probably the same reason you don't, but to a leaser extent |
ESP Bt Proxy is stable only with 2 TRV. I'm using BT Proxy on ESP32 for Home Assistant for almost 1.5 year for my 4 pcs TRV. As long as I have active 2 BT proxy device all working very well, until i disconnect one of them. Maximum limit is 2pcs TRV per one BT Proxy. |
Could you please provide the instructions? Thanks! 😊 |
Hi folks,
first - thanks for the awesome integration. It works extremely well with devices connected to my primary BT dongle.
I have two thermostats that are further away and connected through an esphome BT proxy (D1 ESP32 Mini). Unfortunately the latter have extreme connection issues and constantly disconnect as you can see below (nr. 2 and 4)
My esp home config is:
and the logs show the following.
The text was updated successfully, but these errors were encountered: