ESP Ble Proxy for Shelly Blu Button

I have set up an ESP esp32_ble_tracker. My Shelly Blu Button are also recognized so far:

[10:19:17.930][D][sensor:135]: 'XXX Button Presence Proxy': Sending state -60.00000 dBm with 0 decimals of accuracy

However, the button events are not arriving in HA. What else do I need to do in the ESP so that it forwards the button presses?

Is that possible?

Add bluetooth_proxy. esp32_ble_tracker is just a (mandatory) dependency.
Read more in the Bluetooth Proxy docs

1 Like

Ok thank I will try that

Added

esp32_ble_tracker:
  scan_parameters:
    active: false
[20:52:45.079][C][esp32_ble_tracker:636]: BLE Tracker:
[20:52:45.079][C][esp32_ble_tracker:637]:   Scan Duration: 300 s
[20:52:45.079][C][esp32_ble_tracker:637]:   Scan Interval: 320.0 ms
[20:52:45.079][C][esp32_ble_tracker:637]:   Scan Window: 30.0 ms
[20:52:45.079][C][esp32_ble_tracker:637]:   Scan Type: PASSIVE
[20:52:45.079][C][esp32_ble_tracker:637]:   Continuous Scanning: YES
[20:52:45.080][C][esp32_ble_tracker:645]:   Scanner State: RUNNING
[20:52:45.080][C][esp32_ble_tracker:646]:   Connecting: 0, discovered: 0, disconnecting: 0

[20:56:15.793][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -57.00000 dBm with 0 decimals of accuracy
[20:56:15.806][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -57.00000 dBm with 0 decimals of accuracy
[20:56:16.523][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -62.00000 dBm with 0 decimals of accuracy
[20:56:16.523][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -50.00000 dBm with 0 decimals of accuracy

[20:57:33.773][D][esp32_ble_tracker:772]: Scan complete, set scanner state to IDLE.
[20:57:33.939][D][esp32_ble_tracker:214]: Starting scan, set scanner state to STARTING.

But see not more and signal is not reaching HA

EDIT:

[21:01:47.545][I][safe_mode:042]: Boot seems successful; resetting boot loop counter

After this message seems to work, but is there a chance that I can see over which proxy the Blu Button is sending the event. Because over ESP the rssi is -70 before it was -90-100 sometime it worked sometimes not.

How can I find out if it works via the ESP?

Where do you search for shelly buttons in HA? They are not in shelly integration, but in BTHome (odd, i know…)

The button is already integrated into BTHome and works perfectly. It is connected to a Shelly 2PM gateway and set up. However, I noticed that it has poor RSSI in its location, sometimes as low as -100 dBm, which is why it sometimes doesn’t work.

For this reason, I thought I would put an ESP nearby. So far, the logs show that the connection with <-70 dBm looks good.

But I don’t know if the button really works via the ESP, and I don’t see the ESP in HA under Bluetooth Adapter or Advertisement Monitor etc. So maybe it’s going over the 2PM :slight_smile:

Have you added bluetooth_proxy: as @JeeCee mentioned?

What’s the content of your yaml? I have this in my proxies and it works:

esp32_ble_tracker:
  id: ble_tracker

bluetooth_proxy:
  active: true

For complete logger output in esphome it’s best to set logger to debug (but only temprarily, after you don’t need it change it back to default):

logger:
  level: DEBUG

you monitor this log from esphome (logs, wireless log).
So you’ll see if your button is received.

Ok its not working. I have randomly the issue with bad connection again

My yaml looks like this after the first post:

captive_portal:

bluetooth_proxy:
  active: true
  id: ble_proxy 

esp32_ble_tracker:
  scan_parameters:
    active: false

binary_sensor:
  - platform: ble_presence
    mac_address: "xxx"
    name: "Trockner Button Presence Proxy"
    timeout: 5min  
    min_rssi: -80 

sensor:
  - platform: ble_rssi
    mac_address: "xxxx"
    name: "Trockner Button Presence Proxy"

I will enable debug. Somehow I thought it’s the default because of this RSSI mesages

Also with DEBUG i have not more logs

[12:45:49.674][C][logger:261]: Logger:
[12:45:49.674][C][logger:261]:   Max Level: DEBUG
[12:45:49.674][C][logger:261]:   Initial Level: DEBUG
[12:45:49.675][C][logger:267]:   Log Baud Rate: 115200
[12:45:49.675][C][logger:267]:   Hardware UART: UART0
[12:45:49.675][C][logger:274]:   Task Log Buffer Size: 768
[12:45:49.675][C][bluetooth_proxy:124]: Bluetooth Proxy:
[12:45:49.675][C][bluetooth_proxy:124]:   Active: YES
[12:45:49.675][C][bluetooth_proxy:124]:   Connections: 3
[12:45:49.676][C][ble_presence:016]: BLE Presence 'Trockner Button Presence Proxy'
[12:45:49.676][C][ble_rssi:017]: BLE RSSI Sensor 'Trockner Button Presence Proxy'
[12:45:49.676][C][ble_rssi:017]:   State Class: 'measurement'
[12:45:49.676][C][ble_rssi:017]:   Unit of Measurement: 'dBm'
[12:45:49.676][C][ble_rssi:017]:   Accuracy Decimals: 0
[12:45:49.676][C][ble_rssi:027]:   Device Class: 'signal_strength'
[12:45:49.676][C][esp32_ble:656]: BLE:
[12:45:49.676][C][esp32_ble:656]:   MAC address: xxxx
[12:45:49.676][C][esp32_ble:656]:   IO Capability: none
[12:45:49.676][C][esp32_ble_tracker:636]: BLE Tracker:
[12:45:49.679][C][esp32_ble_tracker:637]:   Scan Duration: 300 s
[12:45:49.679][C][esp32_ble_tracker:637]:   Scan Interval: 320.0 ms
[12:45:49.679][C][esp32_ble_tracker:637]:   Scan Window: 30.0 ms
[12:45:49.679][C][esp32_ble_tracker:637]:   Scan Type: PASSIVE
[12:45:49.679][C][esp32_ble_tracker:637]:   Continuous Scanning: YES
[12:45:49.680][C][esp32_ble_tracker:645]:   Scanner State: RUNNING
[12:45:49.680][C][esp32_ble_tracker:646]:   Connecting: 0, discovered: 0, disconnecting: 0
[12:45:49.680][C][bluetooth_proxy.connection:091]: BLE Connection:
[12:45:49.680][C][esp32_ble_client:071]:   Address: 
[12:45:49.680][C][esp32_ble_client:071]:   Auto-Connect: FALSE
[12:45:49.680][C][esp32_ble_client:075]:   State: IDLE
[12:45:49.966][C][bluetooth_proxy.connection:091]: BLE Connection:
[12:45:49.966][C][api:211]: Server:
[12:45:49.966][C][api:211]:   Address: esp-ble-proxy.local:6053
[12:45:49.966][C][api:211]:   Listen backlog: 4
[12:45:49.966][C][api:211]:   Max connections: 8
[12:45:49.966][C][api:218]:   Noise encryption: YES
[12:45:49.966][C][mdns:177]: mDNS:
[12:45:49.966][C][mdns:177]:   Hostname: esp-ble-proxy
[12:46:21.098][D][binary_sensor:047]: 'Trockner Button Presence Proxy': ON
[12:46:21.104][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -75.00000 dBm with 0 decimals of accuracy
[12:46:21.198][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -74.00000 dBm with 0 decimals of accuracy
[12:46:21.404][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -68.00000 dBm with 0 decimals of accuracy
[12:46:21.404][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -68.00000 dBm with 0 decimals of accuracy
[12:46:23.552][D][sensor:135]: 'Trockner Button Presence Proxy': Sending state -83.00000 dBm with 0 decimals of accuracy

But no action in HA.

Do I have configure something on the Shelly device or disconnect from the Shelly BLE gateway?

Yes, that’s mandatory if this shelly BLE gateway isn’t integrated into HA so it can’t send data to HA.
Only one BT connection can exist at a time. I learned this hard way, too, with LD2410 proximity sensor - once it worked, then it suddenly didn’t. Turned out that i when changed devive’s parameters with android app device switced from HA to app…

If possible try to add shelly gateway into HA.

I’m not sure if I understand your post correctly.

I have Shelly 2PM (gen3) for my roller shutters, which have an integrated BLE gateway. Of course, I have integrated all of them into HomeAssistant.

My Shelly Blu Buttons are connected to the Shelly 2 PM and the forwarding works perfectly. Except for one, because it’s in the basement.

That’s why I’m using the ESP as a workaround, so the connection is already better, as you can see from the logs. However, no press events are coming through.

So my question was: do I still need to actively connect the Shelly Blu Button to the ESP as well as to the Shelly 2pm, which you have to actively enter in the app?

Do I also have to deregister the Shelly Blu Button from the Shelly 2PM?

well, now i start to understand less and less, too.
So, is this correct: you have shelly blu button and shelly 2PM as BLE gateway. Then you also have one esp32, programmed with esphome as bt proxy. When you press your Shelly BLU button it doesn’t appear in BTHome section in HA. Correct?

I have shelly button tough, i have 3 esp’s as bt proxy and shelly plus plug, which also acts as proxy. I also have BT enabled in my intel nuc and it’s acting as BTproxy, too.
When i bought shelly button i didn’t do anything (if i remember correctly…), no registration, nothing, i just inserted battery, pressed the button and it appeared in HA. I did register button in shelly app, but only to update it’s fw.

Thats correct

No, the Shelly Blu Button is already set up in BTHome, BUT sometimes I have poor RSSI via the Shelly 2PM Shelly Gateway because the distance is too far, i.e., some clicks produce a sound, but no signal arrives in HA or the 2PM Shelly Gateway.

That’s why I use the ESP, because I can place it closer to the Shelly Blu Button. As you can see in the log, this gives me better reception, but no clicks are received by HA via the ESP either (I assume). I also can’t see whether the button clicks are actually being routed via the ESP.

Ah good to know maybe then I should deregister from Shelly 2PM maybe then its working.

Is your new esphome btproxy stated in your bluetooth visualization (settings, bluetooth, visualization)? Blue circles show btproxy devices, and you can see for each BLE device where it’s connected to.

I take new Shelly Blu Button press the button popped up in HA directly to this seems to work over the ESP32 Gateway :slight_smile:

That makes sense.
In principle you can “bind” a BT device to esphome:

binary_sensor:
  - platform: ble_presence
    mac_address: "xxx"
    name: "Trockner Button Presence Proxy"

AND send it to HA over Bluetooth proxy, but I don’t know if that applies as well to a device which establishes an active connection

bluetooth_proxy:
   active: true

I suggest to choose 1; proxy or bind to esphome

Your new button is not bound, so it works.