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

[Fix Released] ESP32 BTProxies not working. #4

Closed
andrei-micu-ro opened this issue Oct 19, 2022 · 306 comments · Fixed by #37 or #42
Closed

[Fix Released] ESP32 BTProxies not working. #4

andrei-micu-ro opened this issue Oct 19, 2022 · 306 comments · Fixed by #37 or #42

Comments

@andrei-micu-ro
Copy link

Hello,

Got a problem where the thermostats are not visible through ESP Home Bluetooth Proxy integration.
The Thermostats were successfully paired using the BT from the server, communicated, all good.
I them moved them away (only reachable through the ESPHome bluetooth_proxy) and they became unavailable.

I only have the "bluetooth_proxy:" added to the esphome yaml and use the Wemos D1 Mini (Wifi & BT). The BT Proxy works as other BT sensors connect and work.

I tried also adding the esp32_ble_tracker without any luck.

@wjarka
Copy link

wjarka commented Oct 19, 2022

Same for me. Were getting "No backend with an available connection slot that can reach address" after I removed the Bluetooth dongle from my Pi :)

@andyxpert
Copy link

andyxpert commented Oct 19, 2022

Extra details:

bleak.exc.BleakError: No device found for address 00:1A:22:16:BA:58

and then

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 171, in connect
reply = await self._bus.call(
File "/usr/local/lib/python3.10/site-packages/dbus_fast/aio/message_bus.py", line 358, in call
await future
asyncio.exceptions.CancelledError

Caused by

File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 170, in connect
async with async_timeout.timeout(timeout):
File "/usr/local/lib/python3.10/site-packages/async_timeout/init.py", line 129, in aexit
self._do_exit(exc_type)
File "/usr/local/lib/python3.10/site-packages/async_timeout/init.py", line 212, in _do_exit
raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

From ESP:
esp32_ble_client:036]: Found device at MAC address [00:1A:22:1A:88:81]
[17:27:46][I][esp32_ble_client:058]: Attempting BLE connection to 00:1a:22:1a:88:81
[17:27:50][I][esp32_ble_client:188]: auth complete. remote BD_ADDR: 001a221a8881
[17:27:50][E][esp32_ble_client:190]: auth fail reason = 0x50

Keep up the good/great work ! Keep on improving the code.
Cheers

@dbuezas
Copy link
Owner

dbuezas commented Oct 19, 2022

@andrei-micu-ro

and use the Wemos D1 Mini (Wifi & BT)
Isn't the d1 mini an esp8266? (No Bluetooth)

@dbuezas
Copy link
Owner

dbuezas commented Oct 19, 2022

@andyxpert it may well ve that you have the Firmware>1.20, in which case you need to pair it with the esp first. I haven't tried this yet, but it may ve enough to hold the device button pressed for 5 seconds or so, and then adding the device in HA (make sure no other Bluetooth adapter is on)
Please write again with the result, if that doesn't work I'll take a deeper look :)

@wjarka
Copy link

wjarka commented Oct 19, 2022

Is there an easy way to check the firmware version btw?

@andyxpert
Copy link

andyxpert commented Oct 19, 2022

No result, tried with different configs in esp (esp32_ble_tracker and bluetooth_proxy both with active true), doesn't seem to work. added verbose logging in esp, will paste below.

[19:26:38][V][bluetooth_proxy:026]: Proxying packet from CC-RT-BLE - 00:1A:22:17:01:0F. RSSI: -77 dB
[19:26:38][VV][api.service:334]: send_bluetooth_le_advertisement_response: BluetoothLEAdvertisementResponse {
  address: 112241082639
  name: 'CC-RT-BLE'
  rssi: -77
  service_uuids: '3E135142-654F-9090-134A-A6FF5BB77046'
  manufacturer_data: BluetoothServiceData {
  uuid: '0x5201'
  data: 'EQ0816664'
}
}
...
[19:26:38][I][esp32_ble_client:058]: Attempting BLE connection to 00:1a:22:17:01:0f
[19:26:38][V][esp32_ble_client:123]: [00:1a:22:17:01:0f] ESP_GATTC_DISCONNECT_EVT, reason 62
[19:26:38][VV][api.service:344]: send_bluetooth_device_connection_response: BluetoothDeviceConnectionResponse {
  address: 112241082639
  connected: NO
  mtu: 23
  error: 62
}

I'll post if something changes

@dbuezas
Copy link
Owner

dbuezas commented Oct 19, 2022

@wjarka

Is there an easy way to check the firmware version btw?

Yes, either:

  • take the batteries out and in again, the screen will show the firmware version.
  • Go to the Developer Tools menu, Services, pick "Fetch EQ3 Serial Number" service, chose your thermostat entity, call the action. Then go to states, pick the thermostat entity and look a the "firmware_version" field

@dbuezas
Copy link
Owner

dbuezas commented Oct 19, 2022

@andyxpert did you try what I said about pairing?

@andyxpert
Copy link

Yes, but nothing happens. I think esp can't pair with the thermostat, think it only works for passive ble devices, as it shows in the log above that it does send messages to homeassistant, but when pairing it somehow doesn't
Maybe esphome will have a release with active connections fixed ?! It is fairly recent for them also to allow active bt proxy

@dbuezas
Copy link
Owner

dbuezas commented Oct 19, 2022

You are right... I must have made a mistake during testing then. I do remember the esp discovering it, but I guess when I connected, it used the bluetooth adapter in my HA machine :/

    @api_error_as_bleak_error
    async def pair(self, *args: Any, **kwargs: Any) -> bool:
        """Attempt to pair."""
        raise NotImplementedError("Pairing is not available in ESPHome.")

@dbuezas
Copy link
Owner

dbuezas commented Oct 19, 2022

I corrected the readme. If you find any way to downgrade the firmware to pre v1.20 let me know. That should actually work.

@dbuezas dbuezas closed this as completed Oct 19, 2022
@wjarka
Copy link

wjarka commented Oct 20, 2022

@dbuezas I will continue here, because this issue is actually Bluetooth Proxies ;).

I adopted the proxies to ESPHome. Unplugged the Bluetooth Dongle from Pi (so I am only left with Bluetooth Proxies).

Logs from ESPHome show nothing useful (potentially logging level too high).

In HA, I got this:

bleak.exc.BleakDBusError: [org.freedesktop.DBus.Error.UnknownObject] Method "Connect" with signature "" on interface "org.bluez.Device1" doesn't exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
...
bleak_retry_connector.BleakNotFoundError: EQ3 Gościnny - /org/bluez/hci0/dev_00_1A_22_14_B6_A2: Failed to connect: [org.freedesktop.DBus.Error.UnknownObject] Method "Connect" with signature "" on interface "org.bluez.Device1" doesn't exist
: The device disappeared; Try restarting the scanner or moving the device closer

I am not sure if by device it means Bluetooth dongle or the thermostat. But it almost seems like your implementation tries to always connect to the thermostat through the same BT adapter?

@wjarka
Copy link

wjarka commented Oct 20, 2022

Then I restarted Hassio and got three different errors for three different thermostats. Logs below:

FIrst

> custom_components.dbuezas_eq3btsmart.python_eq3bt.eq3bt.BackendException: Can't find device

Second

bleak_retry_connector.BleakConnectionError: Sypialnia - 00:1A:22:14:AF:20: Failed to connect: No backend with an available connection slot that can reach address 00:1A:22:14:AF:20 was found

Third

bleak_retry_connector.BleakNotFoundError: EQ3 Rurkowy - 00:1A:22:14:B7:75: Failed to connect: Timeout waiting for connect response

I hope that helps.

@dbuezas
Copy link
Owner

dbuezas commented Oct 20, 2022

I think this may be because the btproxy is not yet connected to HA. The component should sooner or later switch to the BTProxy, and then you will get a different error :/

@dbuezas
Copy link
Owner

dbuezas commented Oct 20, 2022

Thanks for the experiments btw

@wjarka
Copy link

wjarka commented Oct 20, 2022

If I should just create a new issue, let me know ;).

@wjarka
Copy link

wjarka commented Oct 20, 2022

I think this may be because the btproxy is not yet connected to HA. The component should sooner or later switch to the BTProxy, and then you will get a different error :/

I can disconnect it tomorrow and wait longer and see what happens. But first I want to make sure it's warm in the house, so don't want to leave it disconnected for the night ;). Let me know if checking that would be useful :)

@wjarka
Copy link

wjarka commented Oct 20, 2022

And maybe that first message is useful. :)

And actually... one of the Bluetooth Proxies may have just connected to a thermostat. This showed up in ESPHome logs:

[19:39:41][D][esp32_ble_client:036]: Found device at MAC address [00:1A:22:14:B6:A2]
[19:39:41][I][esp32_ble_client:058]: Attempting BLE connection to 00:1a:22:14:b6:a2
[19:39:44][I][esp32_ble_client:142]: Service UUID: 0x1800
[19:39:44][I][esp32_ble_client:143]:   start_handle: 0x100  end_handle: 0x151
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 0x2A00, handle 0x111, properties 0x2
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 0x2A01, handle 0x121, properties 0x2
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 0x2A02, handle 0x131, properties 0x2
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 0x2A03, handle 0x141, properties 0x8
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 0x2A04, handle 0x151, properties 0x2
[19:39:44][I][esp32_ble_client:142]: Service UUID: 0x1801
[19:39:44][I][esp32_ble_client:143]:   start_handle: 0x200  end_handle: 0x220
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 0x2A05, handle 0x211, properties 0x22
[19:39:44][I][esp32_ble_client:142]: Service UUID: 0x180A
[19:39:44][I][esp32_ble_client:143]:   start_handle: 0x300  end_handle: 0x321
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 0x2A29, handle 0x311, properties 0x2
[19:39:44][I][esp32_ble_client:142]: Service UUID: 3E135142-654F-9090-134A-A6FF5BB77046
[19:39:44][I][esp32_ble_client:143]:   start_handle: 0x400  end_handle: 0x430
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 3FA4585A-CE4A-3BAD-DB4B-B8DF8179EA09, handle 0x411, properties 0xa
[19:39:44][I][esp32_ble_client.service:057]:  characteristic D0E8434D-CD29-0996-AF41-6C90F4E0EB2A, handle 0x421, properties 0x1a
[19:39:44][I][esp32_ble_client:142]: Service UUID: 9E5D1E47-5C13-43A0-8635-82AD38A1386F
[19:39:44][I][esp32_ble_client:143]:   start_handle: 0xff00  end_handle: 0xff07
[19:39:44][I][esp32_ble_client.service:057]:  characteristic E3DD50BF-F7A7-4E99-838E-570A086C666B, handle 0xff02, properties 0x38
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 92E86C7A-D961-4091-B74F-2409E72EFE36, handle 0xff05, properties 0x8
[19:39:44][I][esp32_ble_client.service:057]:  characteristic 347F7608-2E2D-47EB-913B-75D4EDC4DE3B, handle 0xff07, properties 0x2

@wjarka
Copy link

wjarka commented Oct 20, 2022

But when updating temperature, I don't think it uses it to communicate. I am not sure how to verify that

@wjarka
Copy link

wjarka commented Oct 20, 2022

Also got a few of those:

[19:54:44][D][esp32_ble_client:036]: Found device at MAC address [00:1A:22:14:B6:A2]
[19:54:44][I][esp32_ble_client:058]: Attempting BLE connection to 00:1a:22:14:b6:a2
[19:54:45][W][esp32_ble_client:089]: connect to 00:00:00:00:00:00 failed, status=133

@dbuezas dbuezas reopened this Oct 20, 2022
@andyxpert
Copy link

Hmm, reopened, so there is something you can do directly in HA component to alter/control the esphome communication with the thermostat ? Interesting, i thought the issue was in esphome after we validated that it works with BT natively (yesterday)
In any case, thumbs up !
Consider releasing more often (after each meaningul change) as it's faster to update from HA than replacing files from Git...
Specifically now when winter is coming and we all need our climate

@dbuezas
Copy link
Owner

dbuezas commented Oct 20, 2022

We could try to find out if BTProxies work on old firmwares at least:

  1. Get the Thermostat firmware version (remove batteries, add again, and it shows it briefly)
  2. Update to v1.0.1 of this component (it fixes the characteristic handle issue in BTProxy)
  3. Enable debug level logs in the component: in configuration.yaml
logger:
  default: warning
  logs:
    custom_components.dbuezas_eq3btsmart: debug
  1. Add the BTProxy and remove the Bluetooth dongle from the computer
  2. Restart HA
  3. Check both HA and BTProxy logs
  4. Post findings :)

@wjarka
Copy link

wjarka commented Oct 20, 2022

I haven't followed the full instruction yet. Just installed 1.0.1 and now I have this:

[22:02:52][D][esp32_ble_tracker:264]: Starting scan...
[22:02:52][W][bluetooth_proxy:110]: Error writing char/descriptor at handle 0x430, status=5

However, after this, it seems to update very fast which with this specific thermostat may mean that it actually used the proxy. But I will need to see tomorrow if it still happens when I unplug the dongle ;)

@andyxpert
Copy link

andyxpert commented Oct 20, 2022

Nothing new, nothing interesting...
Same lack of connection when visible only to esp32.

[Kitchen Thermostat] Broken connection [retry 1/1]: Kitchen Thermostat - 00:1A:22:17:01:0F: Failed to connect:
[Kitchen Thermostat] Error updating, will retry later: Kitchen Thermostat - 00:1A:22:17:01:0F: Failed to connect:

but i also have this:

[Kitchen Thermostat] Failed paring: Pairing is not available in ESPHome.

Hope it helps

@wjarka
Copy link

wjarka commented Oct 20, 2022

Nothing new, nothing interesting... Same lack of connection when visible only to esp32.

[Kitchen Thermostat] Broken connection [retry 1/1]: Kitchen Thermostat - 00:1A:22:17:01:0F: Failed to connect: [Kitchen Thermostat] Error updating, will retry later: Kitchen Thermostat - 00:1A:22:17:01:0F: Failed to connect:

but i also have this: [Kitchen Thermostat] Failed paring: Pairing is not available in ESPHome.

Hope it helps

I got those messages too, but then it worked. But again I don’t know if it fell back to the dongle or actually worked through proxy. Will play with it tomorrow and report back.

@andyxpert
Copy link

andyxpert commented Oct 20, 2022

It's most probably through the dongle.

i got this eventually:

21:25:25][V][bluetooth_proxy:026]: Proxying packet from  - 00:1A:22:1A:88:81. RSSI: -77 dB
[21:25:25][D][esp32_ble_client:036]: Found device at MAC address [00:1A:22:1A:88:81]
[21:25:27][V][esp32_ble_client:181]: ESP_GAP_BLE_SEC_REQ_EVT a
[21:25:27][V][esp32_ble_client:096]: [00:1a:22:1a:88:81] ESP_GATTC_CONNECT_EVT
[21:25:27][V][esp32_ble_client:086]: [00:1a:22:1a:88:81] ESP_GATTC_OPEN_EVT
[21:25:27][I][esp32_ble_client:188]: auth complete. remote BD_ADDR: 001a221a8881
[21:25:27][E][esp32_ble_client:190]: auth fail reason = 0x50

But still not working in HA.
Brought in range of Dongle, it appeared and works, then moved far away (so it's ESP only) and when I set a temp it says:

This error originated from a custom integration.

Logger: homeassistant.core
Source: custom_components/dbuezas_eq3btsmart/python_eq3bt/eq3bt/bleakconnection.py:70 
Integration: dbuezas EQ3 Bluetooth Smart Thermostats 
First occurred: 12:03:00 AM (1 occurrences) 
Last logged: 12:03:00 AM

Error executing service: <ServiceCall climate.set_temperature (c:01GFVJW7D49DJFWA2TAXEHCAZB): entity_id=['climate.kitchen_thermostat'], temperature=29.0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 171, in connect
    reply = await self._bus.call(
  File "/usr/local/lib/python3.10/site-packages/dbus_fast/aio/message_bus.py", line 358, in call
    await future
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:
...
bleak_retry_connector.BleakNotFoundError: Kitchen Thermostat - 00:1A:22:17:01:0F: Failed to connect: 

sooooo still not working, though you must be on the right track as ESP connects (somehow) to the Thermostat

@dbuezas
Copy link
Owner

dbuezas commented Oct 21, 2022

Then I just need the firmware version. If any of you has v<1.20 and it still doesn't work, then it may not be pairing after all and maybe something can be done

@wjarka
Copy link

wjarka commented Oct 21, 2022

The one I tested yesterday was 1.20.

I will check the other ones and follow the full instructions today :)

@maciekelga
Copy link

maciekelga commented Mar 9, 2023

I have checked my logs. I am getting only some messages during or right after restart BT Proxy. Only from time to time, I will get message about some issue with disconnecting device - I don t have it now but is say something that is done before disconnecting properly device or similar - it is like 1 per day /1 or per 2-3 days.
But I`m using 4 TRV with 2 BT Proxy.

@M4Marc
Copy link

M4Marc commented Mar 9, 2023

OK thank you for this information but then it seems to be a different problem in my case.

@dbuezas
Copy link
Owner

dbuezas commented Mar 9, 2023

Are you on the latest Home Assistant and ESPHome versions?
Did you change any of the configurations of the EQ3 via options?

@M4Marc
Copy link

M4Marc commented Mar 9, 2023

@dbuezas yes i am running the latest esphome and the latest HA version.I have changed many Options in the passt to fix the problems without any effect.One thing i could Not figure Out till yet how can i bind thermostats to a specified Proxy or isnt it possible ?!

@maciekelga
Copy link

@M4Marc did You tried first with one TRV? I recommend You play first with one TRV to see if is working good and then increase value of TRV connected to HA.
I think is not possible to assign to particular proxy.

@dbuezas
Copy link
Owner

dbuezas commented Mar 9, 2023

@maciekelga all good ideas and correct 👍.

@M4Marc Can you try removing a thermostat, disabling the bluetooth adapter, restarting HA, waiting for it to be discovered automatically via BTProxy and adding it that way? There is a slight chance that the mac address of the TRV reported by the USB adapter is not the same as the BTProxy (I know this to be the case when running HA directly from a Mac)

@wjarka
Copy link

wjarka commented Mar 9, 2023

For me i have decided to quit for this Moment because the configuration was never a stable one. Also i have had a huge amount of Errors in my log Files (over 100.000 thousend )so it couldnt be good for the hole system.

Can you give some examples of the error messages?

@M4Marc
Copy link

M4Marc commented Mar 9, 2023

I will be Back tomorrow and give you the informations thank you for your interests in advance

@moscito1010
Copy link

moscito1010 commented Nov 18, 2023

@Eroli
i have any questions about your solution. can you send me a mail [email protected] please.
best regards

Hello all,

this is not the best place, but tasmota has been referenced here, for which I would like to thank you very much. I have now switched from ESPHome to Tasmota, which uses the NimBLE library, which is able to handle pairing. However, still no pin is required (for firmware versions 1.1, 1.2 and 1.4), instead the communication works somehow out of the box. I assume the authentication callback is not evaluating the pin input, but is always returning true. For Tasmota you have to know a bit about programming in C, but it's really not rocket science.

I would like to give you a short example. After you have compiled tasmota-bluetooth (and included all modules you need), you can check in the console via "TRV devlist" which devices have been found. I had to find out that the range of the Heltec WiFi Kit V2 modules I use is really not good (i am testing around a bit with ESP32-Wroom modules now). After a few meters, the signal level dropped so low that reliable communication is no longer possible. The performance of my bluetooth dongle on the Raspberry was much better. Nevertheless, you can of course place the small modules much better and more power-saving in the appartment ;-)

When tasmota is running, you create the following configuration for the MQTT data in Home Assistant to create a climate sensor:

mqtt:
  climate:
    - name: myroom_myradiatorid
      modes: ["off", heat, auto]
      min_temp: 4.5
      max_temp: 23.0
      temp_step: 0.5
      precision: 0.1
      mode_command_topic: cmnd/**%tasmota_XXXXXX%**/EQ3/**%EQ3MAC%**/mode
      temperature_command_topic: cmnd/**%tasmota_XXXXXX%**/EQ3/**%EQ3MAC%**/settemp
      temperature_state_topic: stat/EQ3/**%EQ3MAC%**
      temperature_state_template: "{{ value_json.temp }}"
      mode_state_topic: stat/EQ3/**%EQ3MAC$**
      mode_state_template: "{{ value_json.hassmode }}"
      current_temperature_topic: tele/**%tasmota_XXXXXX%**/SENSOR
      current_temperature_template: '{{ value_json["BME280-77"].Temperature - 2 }}'

You have to adapt %tasmota_XXXXXX% and %EQ3MAC% to your own identifiers. The current_temperature_topic/template is not required, but you can directly integrate temperature sensors on your tasmota device into the climate sensor.

Furthermore, i created additional sensors for the valve position and the last updated timestamp. These should be also inside the mqtt node of your configuration:

  sensor:
    - name: myroom_temperature
      state_topic: tele/**%tasmota_XXXXXX%**/SENSOR
      value_template: '{{ value_json["BME280-77"].Temperature }}'
      unit_of_measurement: "°C"
    - name: myroom_humidity
      state_topic: tele/**%tasmota_XXXXXX%**/SENSOR
      value_template: '{{ value_json["BME280-77"].Humidity }}'
      unit_of_measurement: "%"
    - name: myroom_myradiatorid_valve
      state_topic: stat/EQ3/**%EQ3MAC%**
      value_template: "{{ value_json.posn }}"
      unit_of_measurement: "%"
    - name: myroom_myradiatorid_lastupdate
      state_topic: stat/EQ3/**%EQ3MAC%**
      value_template: "{{ as_local(as_datetime(value_json.stattime)).strftime('%e. %b %H:%M') }}"

After that you should be able to populate your climate sensor in your dashboard. For example, i am using the simple-thermostat card which looks like this:

  - type: custom:simple-thermostat
    entity: climate.myroom_myradiatorid
    header:
      name: Heating Name
      icon: mdi:heating-coil
    control:
      hvac:
        cool: false
    sensors:
      - entity: sensor.myroom_myradiatorid_valve
        name: Valve
        icon: mdi:gauge
      - entity: sensor.myroom_myradiatorid_lastupdate
        name: Last Update
        icon: mdi:clock-check-outline

As you see, the sensors myroom_temperature and myroom_humidity are not used in the UI at this place. However, if you want to include those data sources into graphs or something like that, you will AFAIK need additional sensors. Also, for example, you could also integrate the humidity into your thermostat card like this:

    sensors:
      - entity: sensor.myroom_myradiatorid_valve
        name: Valve
        icon: mdi:gauge
      - entity: sensor.myroom_humidity
        name: Humidity
        icon: mdi:water
      - entity: sensor.myroom_myradiatorid_lastupdate
        name: Last Update
        icon: mdi:clock-check-outline

In my case the result looks like this: image

However, the workaround via tasmota also has a few disadvantages. There is no convenient integration with Home Assistant like with ESPHome. In addition, the latency is higher, which does not matter for thermostats, but if PIR sensors are connected to the ESP, then the latency increases when switching on the lights if motion has been detected (or you implement the logic yourself in tasmota).

Maybe these comments will help someone to integrate their EQ3 thermostats into Home Assistant - at least as long as ESPHome and eq3btsmart do not support pairing...

i have any questions about your solution. can you send me a mail [email protected] please.
best regards

@maciekelga
Copy link

My TRV since last winter are very stable, I have no more issue when working together with ESP32 Proxy.

@moscito1010
Copy link

@maciekelga

Actually?
I've been trying for 2 months.
My TRV's are EQ-3 Equiva Bluetooth with 4 pins and 6 pin firmware.
It can't be the reception, I use external antennas and all TRV's are found immediately, the location of the ESP32 is central, even the BLE connections to my LFP BMS are found :-)
Out of desperation and because I thought I just wasn't smart enough for this job, I entrusted it to a home assistant nerd. He gave his best here for 4 hours and then gave up with the words "the shit isn't going as it should".

Sorry if I say that because I read your words but I don't believe them.
I don't know anyone yet for whom the combination of EQ-3 BLE TRV and ESPhome ESP32 BLE proxies works and I would pay for it if it worked. I have 18 of them.........

@dbuezas
Copy link
Owner

dbuezas commented Nov 19, 2023

Wow, 18 is a lot! I have 7 and thought I was exaggerating.

Have you ever paired them with a phone? I read somewhere that once paired, they ignore every other request. I assume you did try long pressing the button and resetting at least one, right?

@maciekelga
Copy link

@moscito1010
I have only 4 pcs at my home. Are working really ok since last winter. I remember at the beginning I struggling a little bit with connections but since I have installed 2 x ESP32 Proxy with external antenna (added piece of wire) are working very stable. Firmware 1.4.4 and 1.4.6, scan interval set to 5min.

I don't know how did You start, but I suggest to delete all of them from HA, in next step turn on just one, and try to fix connection with one. Once is configured, set scan interval for 5min.

Afternoon I can send You my configuration of ESP32 Proxy.

@dbuezas
I had all of my TRV paired with mobile app, now are working only with HA.

@Eroli
Copy link

Eroli commented Nov 20, 2023

@maciekelga

Actually? I've been trying for 2 months. My TRV's are EQ-3 Equiva Bluetooth with 4 pins and 6 pin firmware. It can't be the reception, I use external antennas and all TRV's are found immediately, the location of the ESP32 is central, even the BLE connections to my LFP BMS are found :-) Out of desperation and because I thought I just wasn't smart enough for this job, I entrusted it to a home assistant nerd. He gave his best here for 4 hours and then gave up with the words "the shit isn't going as it should".

Sorry if I say that because I read your words but I don't believe them. I don't know anyone yet for whom the combination of EQ-3 BLE TRV and ESPhome ESP32 BLE proxies works and I would pay for it if it worked. I have 18 of them.........

Hi @moscito1010 ,
recently i had to update all my tasmotas of the solution i've posted some months ago. I forked the newest tasmota source code for that and implemented a TRV filter based on the their MAC addresses. This is necessary, since otherwise tasmota tries to reach out to all TRVs somehow available. However, if they are far away and the connection quality is bad, quite big latencies and in general a worse reliabiliy is the result. Therefore, the filter ensures that every tasmota is just connecting to the TRVs which provide a stable connection.

In total, i have 12 TRVs, which are controlled by 5 ESP32 based on tasmota. Using the MAC filtering i can achieve a latency ranging from 3s (normal) to up to approximately 60s (worst case).

Furthermore, i stepped away from the Heltec Wifi Kit 32, as i noticed the wireless connection of those boards is not really good. Using simple Wroom32 boards i get much more stable results.

If you are still interested in this solution, i can help you out setting something up!

EDIT: Before i updated my tasmota solution i also tried, once again, the ESP32 bluetooth proxy feature, but ran into problems with some TRVs working on an older firmware version. Using tasmota, things are working quite reliable independent of the TRV firmware used. Also for TRVs working with a newer firmware version, the tasmota solution is more stable and reacts a lot faster than the approach based on bluetooth proxies - at least in my opinion and based on the experiments i did with some TRVs.
Using tasmota, you can also add temperature/humidity/presence sensors or things like that. However, if you want to also control LEDs for lighting and want them to react really fast, i strongly recommend using ESPhome. Actually, in my case, i divided that: Fast responding elements like LEDs are controlled using ESPHome, while non time-critical components like temperature, humidity or presence sensors are running on tasmota. They communicate with HA using MQTT and are, therefore, working with a bit higher latencies.

@moscito1010
Copy link

@Eroli
Yes, I would be very interested in your solution but I read that you are much more into the theme.
For me it's always a lot of mental exercise with a flat learning curve :-)
Would you like to contact me by email? I think my ignorance could flood this area improperly :-)
I think the solution should be read here in a cleaned-up form. Simply clearer.
Ich glaube du sprichst deutsch oder? :-)
Greetz from lower saxonia

@M4Marc
Copy link

M4Marc commented Nov 23, 2023

Hallo everybody,
since last year i try to get esp / Proxy run with the eq3.I have the same opinion as written before.No stable solution until yet so i am very interestet in the Tasmota solution too.I am even from lower saxon ;).Please make an Post with the solution i think it would help many people to sleep well in future....

@moscito1010
Copy link

It's a shame that there's no reaction, but maybe the solution is totally secret and can only be shared with the Illuminati :-)
@Eroli
So use the app...

@dbuezas
Copy link
Owner

dbuezas commented Dec 8, 2023

I am not using btproxys I found them to barely work with these thermostats, but others say it works fine for them. Maybe it depends on how many bluetooth devices are in the surroundings or some other external factor. I use:

  • 2 bluetooth dongles with antenna
  • An automation that resets them if an eq3 is unavailable for 10 minutes (this should happen automatically, but I found the automation fixes it faster). It calls this bash script created with gpt's help

@moscito1010
Copy link

moscito1010 commented Dec 9, 2023

I am not using btproxys I found them to barely work with these thermostats, but others say it works fine for them. Maybe it depends on how many bluetooth devices are in the surroundings or some other external factor. I use:

* 2 bluetooth dongles with antenna

* An automation that resets them if an eq3 is unavailable for 10 minutes (this should happen automatically, but I found the automation fixes it faster). It calls [this bash script](https://gist.github.com/dbuezas/74c18293c22e6e31bfeb332fa826527f) created with gpt's help

@Eroli blames him for changing the BLE Tasmota version. That sounds very promising.
Since I operate a lot of TRV's, I can't prevent the different ESP's from finding some of the same TRV's.
The possibility of entering e.g. 3 TRVs for each ESP would be helpful so that the ESPs don't find each other dead.
Each ESP can see between 3 and 8 thermostats...

addition:
Of course I downloaded the modified Tasmota from @Eroli but I can't find any way to enter the MAC addresses there.
I hoped that Eroli would write something about it here

@moscito1010
Copy link

moscito1010 commented Dec 9, 2023

I didn't understand that Eroli had a special brunch for that. I didn't see the other branch.

For understanding, a question to @Eroli
I have added the following lines.

// !!! Remember that your changes GOES AT THE BOTTOM OF THIS FILE right before the last #endif !!!
*/

#define USE_EQ3_ESP32
#define USE_BLE_ESP32
#define RADIATOR_1 "\x00\x1a\x22\x12\x0d\x74" // Kitchen
#define RADIATOR_2 "\x00\x1a\x22\x12\x3e\x00" // Input
#define RADIATOR_3 "\x00\x1a\x22\x12\x36\x05" // Bad

#endif // USER_CONFIG_OVERRIDE_H

All TRVs that are nearby are still displayed in the BLE menu item and nothing has changed in the behavior of the ESPs.
The ESP is still trying to process the data of all TRVs found.

@Eroli
Copy link

Eroli commented Dec 10, 2023

Hello everyone,

excuse the late response, but I am currently very busy at work. Moscito1010 is right, I have created a Tasmota fork and implemented my changes there, which are very rudimentary. I also think a fork is best here as I see the MAC filter as a special case which would hardly be of benefit to most Tasmota users.
You can find the fork here:
https://github.com/Eroli/Tasmota

The biggest changes can be found in tasmota/tasmota_xdrv_driver/xdrv_85_esp32_ble_eq3_trv.ino, for example in the matchPrefix function, in which the hardcoded MAC addresses are filtered.

You can then parameterize the MAC filters in tasmota/user_config_override.h. In my case, for example, it looks like this:

// First Part: General Settings (WiFI, MQTT)
// WiFi
#undef  STA_SSID1
#define STA_SSID1         "MyWIFISSID"

#undef  STA_PASS1
#define STA_PASS1         "MyWIFIPassword"

// MQTT
#undef  MQTT_HOST
#define MQTT_HOST         "192.168.x.y"
#undef  MQTT_PORT
#define MQTT_PORT         1883
#undef  MQTT_USER
#define MQTT_USER         "MyMQTTUser"
#undef  MQTT_PASS
#define MQTT_PASS         "MyMQTTPassword"

// Second Part: Include the required modules
// Include BLE Interface
#ifdef USE_BLE_ESP32
   #undef USE_BLE_ESP32
#endif
#define USE_BLE_ESP32

// Include EQ3 Driver
#ifdef USE_EQ3_ESP32
   #undef USE_EQ3_ESP32
#endif
#define USE_EQ3_ESP32

// Enable Rules
#ifdef USE_RULES
   #undef USE_RULES
#endif
#define USE_RULES

// Third part: Room Definition. (Un)comment here to change the ESP settings according to the desired room
// Define some rooms
// Bath
#ifdef ROOM_BATH
    #undef ROOM_BATH
 #endif
#define ROOM_BATH
// LivingRoom
// #ifdef ROOM_LIVINGROOM
//     #undef ROOM_LIVINGROOM
//  #endif
// #define ROOM_LIVINGROOM

// Fourth part: Room-Settings: Determine a running configuration only once, then select your ESP configuration in part three
// Room-Specific Parameters
#ifdef ROOM_LIVINGROOM
   #define FRIENDLY_NAME "Tasmota-LivingRoom"
   #define RADIATOR_1 "\x00\x01\x02\x03\x04\x05"   // Radiator A Example MAC 00:01:02:03:04:05
   #define RADIATOR_2 "\x06\x07\x08\x09\x0a\x0b"   // Radiator B Example MAC 06:07:08:09:0A:0B
   #define RADIATOR_3 "\x0c\x0d\x0e\x0f\x11\x12"   // Radiator C Example MAC 0C:0D:0E:0F:11:12
   #define RADIATOR_4 "\x13\x14\x15\x16\x17\x18"   // Radiator D Example MAC 13:14:15:16:17:18
   #define RADIATOR_5 "\x19\x1a\x1b\x1c\x1d\x1e"   // Radiator E Example MAC 19:1A:1B:1C:1D:1E

   #define USE_I2C
   #define USE_SHT3X
   #define USE_BH1750
#endif

#ifdef ROOM_BATH
  #undef  FRIENDLY_NAME
  #define FRIENDLY_NAME "Tasmota-ShowerBath"

  #define RADIATOR_1 "\x1f\x20\x21\x22\x23\x24"   // Radiator F Example MAC 1F:20:21:22:23:24
  #define RADIATOR_2 "\x25\x26\x27\x28\x29\x2a"   // Radiator G Example MAC 25:26:27:28:29:2A
  
   #define USE_I2C
   #define USE_SHT3X
   #define USE_BH1750
#endif

Since I rarely change the room-specific things (fourth part), I actually only have to change the set room in the third part of the code snippet, depending on which ESP I want to flash.
The living room ESP will, therefore, only contact thermostats A-E and the ESP in the bathroom only thermostats F and G. My sensors also have temperature and humidity sensors (SHT3X) and brightness sensors (BH1750). Some sensors also use a Doppler radar module (RCWL 0516) for motion detection (through the housing). For this I also need the rules, which are activated in the second part. I also set the WLAN password and the settings for the MQTT connection statically in user_config_override.h (first part).

In my case, I build the firmware with the tasmota32-DE profile and then flash it onto the ESP.

After the ESP has been flashed, it only takes a few seconds for it to detect the thermostats. In the web interface of tasmota, in my case in German, you can check this via Consoles --> Console --> TRV devlist. The answer looks something like this:

13:13:37.255 MQT: stat/tasmota_ABCDEF/EQ3 = {"devices":{"000102030405":-93}}

So, only Thermostat A is connected with a signal strength (RSSI) of -93dBm. If everything has worked, only the thermostats that you have set in user_config_override.h will be displayed in this console output. If other thermostats are displayed, you have made an error when compiling/flashing. If fewer thermostats are displayed, be patient or it may be that the missing thermostats have too poor signal quality (RSSI).

@Mosquito1010: I would be interested to find out why this fork is not working for you. Are you sure you compiled and flashed the FW correctly?

@ALL: I think the concept has become clear. You determine in advance which ESP should communicate with which TRVs. Verify your selection in the Tasmota console after flashing. In my case, communication becomes relatively unstable from an RSSI of -100 to -110 dBm, so I then try to query this thermostat via an ESP with better connection quality so that the latency of the overall system remains acceptable.
Tasmota queries all thermostats sequentially. As soon as the communication with one thermostat gets stuck, this instability can affect all other thermostats, as Tasmota only continues with the subsequent thermostats after a few timeouts and retries...

As soon as the connection between the tasmotas and the thermostats is working fine, you may start implementing those thermostats in HomeAssistant as outlined here: #4 (comment)

If there are any further questions, I will be happy to help. If someone is inexperienced with C or flashing ESPs, then we will certainly find a solution...

Best regards!

@moscito1010
Copy link

@Eroli
ESP run's now. I was the error :-)

Yes, I have questions about Home Assistant integration. Since this is already pretty off-topic and the problem is officially closed, I'll just take the plunge :-)

Unfortunately, I have to admit that I'm a total HA boon and my learning curve is rather flat in this area.

You then bring the individual sensor values into the HA via configuration.yaml using mqtt? This will be easy, I've already looked at it on the HA website.

Is there anything to consider or do you have any other tips?

Herzlichen Dank das du deine knappe Freizeit opferst um deine Lösung zu teilen. Mir hat es sehr weiter geholfen.

@Eroli
Copy link

Eroli commented Dec 20, 2023

@Eroli ESP run's now. I was the error :-)

Yes, I have questions about Home Assistant integration. Since this is already pretty off-topic and the problem is officially closed, I'll just take the plunge :-)

Unfortunately, I have to admit that I'm a total HA boon and my learning curve is rather flat in this area.

You then bring the individual sensor values into the HA via configuration.yaml using mqtt? This will be easy, I've already looked at it on the HA website.

Is there anything to consider or do you have any other tips?

Herzlichen Dank das du deine knappe Freizeit opferst um deine Lösung zu teilen. Mir hat es sehr weiter geholfen.

Hi Moscito1010,

I'm glad to hear that it's working for you now. Are you happy with the reliability and latency? Especially compared to the variant via BTProxy?

Exactly, you have to define your sensors in the configuration.yaml file. I think I've already explained a lot about this in this comment, but if you still have questions or problems, please let me know.
After a recent update, I had to add an entry in the SimpleThermostat control because I think a translation in this plugin broke:

    control:
      hvac:
        _name: ' Aktion '

But you can also leave the string empty, the buttons are quite self-explanatory, I think.

A tip: There is a small but quite smart program called MQTTExplorer. This is very helpful to see what information is provided via MQTT and how you can access it and visualize it in HA. In this way, you could, for example, pick up the window-open status of the thermostats. I haven't implemented this myself because the thermostats only react very slowly anyway (and in my case only when the window is wide open), but it might still be quite nice.

Kein Problem, es freut mich, wenn ich helfen konnte. Die alten Bluetooth-Thermostate sind zwar manchmal etwas zickig und die Kommunikation nicht 100%ig zuverlässig, aber es wäre schade diese entsorgen zu müssen, nur damit man sie besser in HA integrieren kann. Abgesehen davon laufen sie ja recht gut und stabil - außer die Batterie ist leer, dann öffnen die das Ventil komplett in meinem Fall, was schon mal sehr ärgerlich sein kann. Also, wenn ein Urlaub bevor steht und das Batterie-Symbol aktiv ist (könnte man auch in HA anzeigen lassen übrigens), unbedingt die Batterie wechseln ;-)

@moscito1010
Copy link

moscito1010 commented Dec 21, 2023

Of course I use mqtt explorer etc.
I have some devices that I evaluate using mqtt>node-red>Influx>Grafana.
Home Assistant drives me crazy because they somehow changed the structure in the config files and after an 18 month break I had the feeling I was sitting in front of a different HA.
But I've always had a hard time with HA. I digress...

All relevant data seems to be available in the broker via mqtt.
grafik

I have a few ESP Wroom with external antennas scattered around the house and am starting small with the first ESP in the living room. I plugged in a temperature sensor (DHT22) and added 2 EQ-3 TVRs to the code.
I prepared the data in the configuration.yaml according to your example for HA

mqtt:
  climate:
    - name: myroom_myradiator1
      modes: ["off", heat, auto]
      min_temp: 5
      max_temp: 26.0
      temp_step: 0.5
      precision: 0.1
      mode_command_topic: cmnd/tasmota_67E854/EQ3/001A22087B17/mode
      temperature_command_topic: cmnd/tasmota_67E854/EQ3/001A22087B17/settemp
      temperature_state_topic: stat/EQ3/001A22087B17  
      temperature_state_template: "{{ value_json.temp }}"
      mode_state_topic: stat/EQ3/001A22087B17   
      mode_state_template: "{{ value_json.hassmode }}"
      current_temperature_topic: tele/tasmota_67E854/SENSOR
      current_temperature_template: '{{ value_json["AM2301"].Temperature - 2 }}'


    - name: myroom_myradiator2
      modes: ["off", heat, auto]
      min_temp: 5
      max_temp: 26.0
      temp_step: 0.5
      precision: 0.1
      mode_command_topic: cmnd/tasmota_67E854/EQ3/001A2208793D/mode
      temperature_command_topic: cmnd/tasmota_67E854/EQ3/001A2208793D/settemp
      temperature_state_topic: stat/EQ3/001A2208793D  
      temperature_state_template: "{{ value_json.temp }}"
      mode_state_topic: stat/EQ3/001A2208793D   
      mode_state_template: "{{ value_json.hassmode }}"
      current_temperature_topic: tele/tasmota_67E854/SENSOR
      current_temperature_template: '{{ value_json["AM2301"].Temperature - 2 }}'

Then I created a map

grafik

with this code

`cards:
  - cards:
      - cards:
          - entity: climate.myroom_myradiator1
            name: Heizung1 Wohnzimmer
            control:
              - hvac
            type: custom:simple-thermostat
          - entity: climate.myroom_myradiator2
            name: Heizung Schlafzimmer
            type: custom:simple-thermostat
            control:
              - hvac
        type: custom:swipe-card
    type: horizontal-stack
  - cards:
      - cards:
          - align_state: center
            entities:
              - color: '#A7C7E7'
                entity: sensor.esp_wohnzimmer_am2301_temperature
                index: 1
                name: Wohnzimmer
            type: custom:mini-graph-card
        type: custom:swipe-card
    type: horizontal-stack
type: custom:vertical-stack-in-card`

I did not understand. For me this immediately leads to an error message.

    control:
      hvac:
        _name: ' Aktion '

@maciekelga
Copy link

Hi,
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 all working very well, until i disconnect one of them. Maximum limit is 2pcs TRV per one BT Proxy.

@evlo
Copy link

evlo commented Feb 27, 2024

But how do you decide which trv uses which proxy? Does btproxy not always relay all ble it sees?

@maciekelga
Copy link

I didn't specify anything, just observe that if I have more than 2pcs TRV per BT Proxy it doesn't work properly.

@dbuezas
Copy link
Owner

dbuezas commented Mar 30, 2024

Has anybody tried pairing with btproxys ? https://esphome.io/components/ble_client#on-passkey-request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment