ESP Bluetooth Proxy - BLE scan not active

I built a ESPPresence device with an esp 32. It was adopted by Home Assistant without issue but I noticed that after 24 hours it hadn’t discovered any devices. Check the logs I see the below over and over again. I am not sure how to fix this.

[09:19:34][W][ota:160]: Magic bytes do not match! 0x47-0x45-0x54-0x20-0x2F
[09:19:34][W][component:204]: Component ota took a long time for an operation (1.40 s).
[09:19:34][W][component:205]: Components should block for at most 20-30ms.
[09:19:34][D][ota:147]: Starting OTA Update from 192.168.1.49...
[09:19:34][D][esp32_ble_tracker:232]: Stopping scan.
[09:19:34][D][esp-idf:000]: E (57202211) BT_BTM: BTM_BleScan scan not active


[09:19:34][D][esp-idf:000]: W (57202215) BT_APPL:  bta_dm_ble_scan stop scan failed, status=0x6

Here is the YAML if that is helpful.

esphome:
  name: bt-proxy
  friendly_name: bt proxy

esp32:
  board: esp32dev
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "removed"

ota:
  password: "removed"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bt-Proxy Fallback Hotspot"
    password: "removed"

captive_portal:

esp32_ble_tracker:
  scan_parameters:
    interval: 1100ms
    window: 1100ms
    active: true

bluetooth_proxy:
  active: true   

Unless you have a wired connection, those shouldn’t be in there per the docs.

And at least when I first setup my first BT Proxies, captive portal couldn’t be used. Can’t remember if that’s in the docs or if it just wouldn’t compile for me. Regardless, I found I had to remove that and have done so everytime I add BT Proxy to a device.

Is your device flashed with esphome or espresense? (They are not the same)

I flashed it with Esphome.

Ok.

Are you trying to upload a new firmware? I see the OTA error message, and the magic byte error looks like you are trying to upload an invalid firmware.

Also as this doesn’t seem to be an Ethernet device, the interval and window shouldn’t be there. See the Bluetooth proxy docs.

I removed the interval portion and it started scanning every 5 min. It found an i beacon I have. Should it not find our phones, watches and such also?

Not unless you’re using an iBeacon app or similar feature in the HA app. Unfortunately, I was never able to get that functionality to work with the HA app.

According to my understanding, you can use various apps to make your phone act as a virtual beacon. I think the HA app also have this feature.

This works but can be unstable due to the way smartphones are programmed to save battery power as their top priority. For example, sometimes the phone will move the virtual beacon app into the “background” which makes it broadcast less frequently (to save battery power). That tends to cause delays in your automations.

Sometimes the phone will shutdown the virtual beacon app completely for power saving reasons or just due to smartphone glitchy behavior. In those cases, the automation will not run until you restart the app.