Bluetooth Proxy crashing? "too many BLE events"d

Hey all, I have a handful of BLE contact sensors (VOCOlinc) that are only compatible with HomeKit. I’ve been able to pair them with Home Assistant using the HomeKit Controller integration, as long as the contact sensor is near my HA box. As soon as I move them to another room, HA no longer registers the open/close broadcasts.

This sounds like a problem that could be solved using Bluetooth Proxies. So I created 2 of them – one using standard ESP32 dev board, another using M5Stack Atom Lite. Neither one seems to be doing anything – but I can’t really tell.

As far as I CAN tell, its one of 2 things:

  1. These VOCOlinc sensors require some sort of 2 way connection, and aren’t supported yet, which doesn’t make sense to me because aside from the pairing process they only send data one way
  2. The Bluetooth Proxies aren’t working correctly. My attention was drawn to an error in the logs about “too many BLE events”. If I do a scan with my computer I can see around 70 BLE devices in range.

Any thoughts?

Here are my logs…

[D][esp32_ble_tracker:222]: Starting scan...
[C][wifi:037]: Setting up WiFi...
[I][wifi:248]: WiFi Connecting to [redacted]...
[W][esp32_ble_tracker:086]: Too many BLE events to process. Some devices may not show up.
[I][wifi:505]: WiFi Connected!
[C][wifi:353]:   Local MAC: [redacted]
[C][wifi:354]:   SSID: [redacted]
[C][wifi:355]:   IP Address: 10.0.1.88
[C][wifi:357]:   BSSID: [redacted]
[C][wifi:358]:   Hostname: 'atom-bluetooth-proxy-d672cc'
[C][wifi:360]:   Signal strength: -54 dB ▂▄▆█
[C][wifi:364]:   Channel: 11
[C][wifi:365]:   Subnet: 255.255.255.0
[C][wifi:366]:   Gateway: 10.0.1.1
[C][wifi:367]:   DNS1: 10.0.1.2
[C][wifi:368]:   DNS2: 0.0.0.0
[D][wifi:514]: Disabling AP...
[C][ota:085]: Over-The-Air Updates:
[C][ota:086]:   Address: 10.0.1.88:3232
[C][api:025]: Setting up Home Assistant API server...
[I][app:062]: setup() finished successfully!
[I][app:102]: ESPHome version 2022.8.3 compiled on Sep 18 2022, 15:13:52
[I][app:104]: Project esphome.bluetooth-proxy version 1.0
[C][wifi:491]: WiFi:
[C][wifi:353]:   Local MAC: [redacted]
[C][wifi:354]:   SSID: [redacted]
[C][wifi:355]:   IP Address: 10.0.1.88
[C][wifi:357]:   BSSID: [redacted]
[C][wifi:358]:   Hostname: 'atom-bluetooth-proxy-d672cc'
[C][wifi:360]:   Signal strength: -54 dB ▂▄▆█
[C][wifi:364]:   Channel: 11
[C][wifi:365]:   Subnet: 255.255.255.0
[C][wifi:366]:   Gateway: 10.0.1.1
[C][wifi:367]:   DNS1: 10.0.1.2
[C][wifi:368]:   DNS2: 0.0.0.0
[C][logger:275]: Logger:
[C][logger:276]:   Level: DEBUG
[C][logger:277]:   Log Baud Rate: 115200
[C][logger:278]:   Hardware UART: UART0
[C][bluetooth_proxy:053]: Bluetooth Proxy:
[C][safe_mode.button:022]: Safe Mode Button 'Safe Mode Boot'
[C][safe_mode.button:022]:   Icon: 'mdi:restart-alert'
[C][esp32_ble_tracker:717]: BLE Tracker:
[C][esp32_ble_tracker:718]:   Scan Duration: 300 s
[C][esp32_ble_tracker:719]:   Scan Interval: 1100.0 ms
[C][esp32_ble_tracker:720]:   Scan Window: 1100.0 ms
[C][esp32_ble_tracker:721]:   Scan Type: ACTIVE
[C][captive_portal:088]: Captive Portal:
[C][mdns:094]: mDNS:
[C][mdns:095]:   Hostname: atom-bluetooth-proxy-d672cc
[C][ota:085]: Over-The-Air Updates:
[C][ota:086]:   Address: 10.0.1.88:3232
[C][api:138]: API Server:
[C][api:139]:   Address: 10.0.1.88:6053
[C][api:143]:   Using noise encryption: NO
[C][improv_serial:032]: Improv Serial:
[D][api:102]: Accepted ::FFFF:A00:103
[D][api.connection:861]: Home Assistant 2022.9.4 (::FFFF:A00:103): Connected successfully
[I][ota:105]: Boot seems successful, resetting boot loop counter.
[D][esp32.preferences:113]: Saving 1 preferences to flash...
[D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[D][esp32_ble_tracker:222]: Starting scan...
[D][esp32_ble_tracker:222]: Starting scan...
[D][esp32_ble_tracker:222]: Starting scan...

Could you please include those logs

The log is in my original post, sorry if I didn’t format them correctly, see 4th line from the top!

Hi @bmtul

There is a 2022.9.5 update now… try this first as looks like some Bluetooth fixes are in there.

if that doesn’t work…

could we see your code? not sure if you did this manually or used the web installer

it can’t be the VOCOlinc sensor as Nick showes off one in the HA YouTube video @ 17:30 in.

Ok wow, thanks so much for pointing this out, that is the exact same sensor I have, so they do work.

Updated to 2022.9.5, no difference.

Here is my code, its pretty basic, I used the web installer for M5Stack, then adopted in HA. Then added my static IP info and re-flashed.

substitutions:
  name: atom-bluetooth-proxy-d672cc
packages:
  esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/[email protected]
esphome:
  name: ${name}
  name_add_mac_suffix: false


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  manual_ip:
    static_ip: 10.0.1.88
    gateway: 10.0.1.1
    subnet: 255.255.255.0
    dns1: 10.0.1.2

Thanks, I did miss that. I thought you were talking about the HA logs.

@Blacky adding to this… when I pulled the Bluetooth diagnostic logs, I can see the ESP devices are receiving the BLE packets I need. But it seems they never make their way to HA to update the sensor. Maybe once every 10x I open the sensor, and the updates are always delayed.

{
          "name": "VOCOlinc-VS1-17E793",
          "address": "F4:90:99:16:DF:77",
          "rssi": -56,
          "manufacturer_data": {
            "76": {
              "__type": "<class 'bytes'>",
              "repr": "b'\\x061\\x00\\xe1[\\x93\\xda\\x94E\\n\\x00\\x0f\\x00\\x01\\x02|k\\xa6\\xe5'"
            }
          },
          "service_data": {},
          "service_uuids": [],
          "source": "atom-bluetooth-proxy-d672cc",
          "device": {
            "__type": "<class 'bleak.backends.device.BLEDevice'>",
            "repr": "F4:90:99:16:DF:77: VOCOlinc-VS1-17E793"
          },
          "advertisement": {
            "__type": "<class 'bleak.backends.scanner.AdvertisementData'>",
            "repr": "AdvertisementData(local_name='VOCOlinc-VS1-17E793', manufacturer_data={76: b'\\x061\\x00\\xe1[\\x93\\xda\\x94E\\n\\x00\\x0f\\x00\\x01\\x02|k\\xa6\\xe5'})"
          },
          "connectable": false,
          "time": 122144.435141697
        },

@bmtul Lets try new code for your Atom Lite. Use the code below. Do a clean build and install.

esphome:
  name: "atom-bluetooth-proxy-d672cc"
  platform: ESP32
  board: m5stack-core-esp32

# For Bluetooth Proxy
esp32_ble_tracker:
###  scan_parameters:
###    interval: 1100ms
###    window: 1100ms
###    active: true

bluetooth_proxy:

# Enable logging
logger:

# Enable Home Assistant API
api:
#  password: !secret esphome_secret

# Over The Air Password (Stops someone on your network accessing files)
ota:
#  password: !secret esphome_secret

# Wifi Information
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

## Optional manual - Static IP
###  manual_ip:
###    static_ip: 10.0.1.88
###    gateway: 10.0.1.1
###    subnet: 255.255.255.0

# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "atom-bluetooth-proxy-d672cc"
#    password: !secret fallback_ap_password

# Captive Portal
captive_portal:

Hi
How do you pass the limit of 24 characters for name?
That has an error in compile.

Just change the name to your liking. I only used that name because @bmtul used it in his code and that was generated by HA. I use the below for an example. “1” being the number of that one and then just go 2, 3, 4, 5 for as many you have. I also use the button and the LED light for identification with a different colour for each.

esphome:
  name: "bluetooth-proxy-1"
  platform: ESP32
  board: m5stack-core-esp32
# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "bluetooth-proxy-1"
#    password: !secret fallback_ap_password

@Blacky the code you sent works - it boots up and says its scanning - but the sensors still aren’t updating like he shows in the video (in the rare case they do update, its delayed by about 15-30 seconds)

I can tell the ESP device is working based on the bluetooth logs - in fact both bluetooth receivers can see my sensors:


"scanners": [
    {
        "type": "ESPHomeScannner",
        "discovered_devices": [{
                "name": "VOCOlinc-VS1-17E793",
                "address": "F4:90:99:16:DF:77",
                "rssi": -65
            },{
                "name": "VOCOlinc-VS1-17ED6B",
                "address": "C4:D7:76:8F:CE:A4",
                "rssi": -92
            }]
        }
/*...*/
/*...*/
/*...*/
    {
        "type": "HaScanner",
        "discovered_devices": [{
            "name": "VOCOlinc-VS1-17E793",
            "address": "F4:90:99:16:DF:77",
            "rssi": -70
        },{
            "name": "VOCOlinc-VS1-17ED6B",
            "address": "C4:D7:76:8F:CE:A4",
            "rssi": -62
        }]
    }
]


Is there anything else I can provide that might help explain what’s going on?

Thanks so much again for taking the time to explore this with me

I am just going to check because last time a user on this forum didn’t have the latest update and I just amused they did even though they said they did.

Your all up to date in ESPHome, HA, and the operating system 9.0 (it is important). There is a new ESPHome one today.Your running supervisor?

It should work as Nick showed it on YouTube.

EDIT: Don’t update to the latest ESPHome 2022.9.0 it has stopped reporting ADC readings. It is reporting to HA but not in the logs

EDIT: ESPHome 2022.9.1 has now fixed the ADC readings and are now showing in the logs. Thanks guys :grinning:

Thanks @Blacky, I think I check all of those boxes:

Home Assistant 2022.9.5
Supervisor 2022.09.1
Operating System 9.0
Frontend 20220907.2 - latest

@bmtul . Before we had Bluetooth proxy I think you linked them to HomeKit. A lot of Bluetooth sensors only like being connected to 1 thing at a time. Just a thought is… or can the sensor be connected still to HomeKit?

Now just thinking out loud. If ESPHome see the sensor connect and disconnect instantly then it should get to HA :heavy_check_mark: (and you must have added your code to mine). The code above you added to your Bluetooth proxy to see the VOCOlinc sensor open and close,… try removing it and just use the code I gave you and nothing else. Make sure nothing else can connect to your VOCOlinc sensor other than your Atom Lite Bluetooth proxy with the code I gave you. Then look in the integration (like Nick did) and see if it reacts fast.

There are some options for adding additional Bluetooth adapters to extend two way communication range in the Bluetooth integration documentation. Personally I use usb to Ethernet extensions to reach all my locks.

The esphome proxies only support one way communication (passive). All HomeKit devices need two way active communication which is still being developed for the esphome proxies which should land in the new few weeks if all goes well.

2 Likes

Thanks Nick, I think you resolved this :+1:

Love your work and thank you again for Bluetooth :grinning:

PS: Hopefully one day they will mesh to each other.

@Blacky Correct they can only be paired to one host at a time, so as soon as I “forgot” them from the Home App, they showed up on the Integrations screen. Pairing process was easy - as long as I was standing near the HA box with the sensor in my hand. Open/close events register here instantly as well.

But as soon as I carry the device into another room, the state no longer updates, it remains whatever it was when I walked out of range. It will stay this way until I reboot HA, when it will change to “Unavailable”

So far I have only used the code you sent - nothing extra. That JSON I posted above was from HA’s bluetooth diagnostics- which shows both the main box and the proxy are seeing the sensor (among some 75 other BLE devices) and still no state updates when I step out of range…

@bmtul

yeah I thought that would be the case. Nick has given us some information and that is

So looks like next month release our Atom lite will be able to have two way active communication if all goes well. Then your VOCOlinc sensor/s will work in the other rooms and around your home as long as your within rage of your Atom lite/s Bluetooth proxy.

Glad you got this far now you will just have to wait.

let us know how you go once this happens.

:wink: :facepunch: