Adding ESPresense flashed ESP-WROOM-32 ESP32 to HA

I got a pack of ESP-WROOM-32 ESP32 and spent 4 hrs going nuts trying to get them on HA reading every doc and post I can find.

What I tried:

  1. Taking an ESP32, clicking “Add Device” in ESP Home dashboard, and following steps. Result: firmware installation seemingly successful, but it doesn’t connect to wifi (blue led not flashing and it doesn’t attempt to acquire IP from DHCP). Retried 10+ times on multiple devices, reinstalled ESP Home add-on, no luck.
  2. Installing firmware via ESPresense website. The ESP32 does connect to Wifi, gets an IP address from DHCP, and displays the ESPresense config panel when the IP is opened from the browser. I set the MQTT server/credentials, see in console it detects bunch of beacons, and it does show up in HA:

But when I try to configure it, I see this:

What key does it want? There is noting on the ESP Home dashboard. Ok, I went there and created a new device, gave it identical name, and skipped the flashing (because that bricks the ESP32 as per #1). I do see encryption key under the API in there. I copy-pasted the key and then I see this -

But that’s not true, there is an api line in the YAML! Is it wrong YAML? I’m so lost.

How do I make ESP32 device work in HA?

The API key is part of the YAML configuration used to flash the device. When you created the new device (naming does not matter) it generated a random API key, but, since that’s not the YAML you used to flash the device, then the API key for your device is different.

Never used ESPresence, but it looks like they are setup to integrate via MQTT instead of adding the device through ESPhome like the screenshot you shared. Do you have an MQTT device entry for it already?

Can you post the code that is flashed to the ESP? (redact sensitive info)

ESPresense and ESPhome are not the same.

I left it yesterday night as “Discovered” (as in the screenshots above). I wasn’t able to get passed those prompts. Today morning no more “Discovered” and I found it as an MQTT device:

But there is nothing whatsoever in ESPHome dashboard. I don’t know if that’s a problem and if I should try to make it appear there. My goal is to add beacons and create automations based on their presence/distance.

Re code that is flashed on ESP - how do I get it? I flashed it using this page: Install Firmware | ESPresense

ESPresense is not ESPHome and will not show up in the ESPHome dashboard. These are completely separate firmware. I wish ESPHome would incorporate ESPresense funcionality so I can use those same devices for bluetooth proxies as well.

Espresence communicates to HA via MQTT and you’ll need to create the appropiate MQTT sensors in YAML to configure HA to use it.

1 Like

Thanks for getting me on the right track! I abandoned the #1 method (ESPHome) and configured bunch of beacons (mostly iPhones and iPads) as sensors by pairing them and adding them to configuration.yaml:

  - platform: mqtt_room
    device_id: "my_ipad"
    name: "iPad Gold"
    state_topic: "espresense/devices/gold_ipad"
    timeout: 10
    away_timeout: 120

I see this:

I’d like to add a chart to the dashboard showing the distance changes over time. Or even the current distance. How can I do that? I tried sensor.ipad_gold.attributes.distance but it doesn’t work.

I got the answer to the above in the configuration topic (Accessing entity attribute in the dashboard and automations - #5 by au78). Thanks all.

You typically don’t go that deep with the MQTT topic. This works for me and will give distance as one of the attributes

  - platform: mqtt_room
    device_id: "iBeacon:redacted"
    name: "Redacted Phone BLE"
    state_topic: "espresense/rooms"
    timeout: 10
    away_timeout: 60

If you used the MQTT ‘configure’ option in the integrations page you can ‘listen’ to the incoming messages.

{
    "id": "iBeacon:redacted",
    "idType": 180,
    "rssi@1m": -55,
    "rssi": -82,
    "raw": 5.91,
    "distance": 5.54,
    "speed": 0.01,
    "mac": "redacted",
    "interval": 1517
}

You can use a template sensor to pull the value from the attributes

template:
  - sensor:
      - name: RedactedPhone BLE Distance
        state: '{{ state_attr("sensor.redacted_phone_ble", "distance") }}'
        unit_of_measurement: "m"
1 Like