Help with yaml for BLE presence

I’m trying to get presence detection working using an ESP32 and Esphome. I was able to flash the ESP and get it into home assistant but I’m having issues with constructing the proper yaml file. Could someone please provide an example I could follow?

Thank you

substitutions:
  name: m5stack-atom-lite-9f8c10-2
  friendly_name: Bluetooth Proxy bedroom

packages:
  esphome.bluetooth-proxy: github://esphome/bluetooth-proxies/m5stack/m5stack-atom-lite.yaml@main

esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}

api:
  encryption:
    key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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

bluetooth_proxy:
  active: true

esp32_ble_tracker:
  scan_parameters:
    active: True # Whether to send scan-request packets to devices to gather more info (like devicename)
    interval: 320ms # suggested 211ms # default 320ms
    window:   300ms # suggested 120ms # default 30ms

Edit: The scan parameters are those recommended for the Bermuda integration - they may not be the ones you need.

Another edit: Oops…

esphome:
  name: ble001
  friendly_name: BLE001

esp32:
  board: wemos_d1_mini32  # Make sure you choose *your* board here!
#  framework:
#    type: esp-idf

# Enable logging
logger:

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

ota:
  - platform: esphome  
    password: !secret ***_***

wifi:
  ssid: !secret ****_****
  password: !secret ****_********
  manual_ip:
    static_ip: 192.***.***.***
    gateway: 192.***.***.***
    subnet: 255.***.***.0
  fast_connect: true  

  ap:
    ssid: "Ble001"
    password: !secret **_***

#captive_portal:

bluetooth_proxy:

esp32_ble_tracker:
  scan_parameters:
    interval: 316ms
    window: 180ms
 
time:
  - platform: sntp
    id: mio_orario
    timezone: Europe/Rome

switch:
  - platform: restart
    name: Riavvio Ble001  

Thank you. I’m trying to keep this as simple as possible. Do I need other software components to make this work other than esphome?

I also have the ESPhome addon, which makes editing yaml and updating a bit simpler. You still need the ESPHome integration, though.

If you want to work on room recognition I recommend the custom component bermuda trilateration, here you can find a great guide for installation and setup

2 Likes

I have the integration installed. For a newbie, what is the best method?

My experience has been that you need the integration and the add-on.

I used the ESPhome bluetooth proxy page to flash my device (a MSStack Atom):

This was automatically discovered by the ESPhome integration, but you need to edit the yaml and flash it a second time for the particular application you are using (in my case Bermuda, mentioned above. Besides the video, there’s a very good wiki.).

The easiest way to handle the second flash and future updates is with the add-on.

The add-on will automatically discover the device and ask if you want to “adopt” it. You then click edit to update the yaml and when you click save it will flash a second time. Be patient - flashing can take several minutes, with seemingly interminable lines of log scrolling past.

1 Like