BT presence detection: compare rssi db and last_changed?

Hi everybody,

I have two esp32 running ESPHome that use the ble_rssi sensor. I registered two Xiaomi MiBands.

One device is in the upstairs bedroom, the other on the downstars office. They provide these sensors

  • sensor.btaz_miband_3 (downstairs office)
  • sensor.btaz_miband_5 (downstairs office)
  • sensor.btsz_miband_3 (upstairs bedroom)
  • sensor.btsz_miband_5 (upstairs bedroom)

How would I best determine whether both bands are likely to be in the upstairs bedroom?

I thought of compairing their db value. However, currently, both devices are within 1 meter next to each other (and about 2 - 3 meters from the ESPhome). Yet one is at -56 db, the other one was at -82 db just now and is now unknown. So I cannot just compare the values and define an offset.

The miband_5 is now switching somewhere between -58 db and -88 db regarding the upstairs bedroom sensor, but also at -91 db in the downstairs office. The downstairs office one has last been updated five minutes ago. However, I thought it would either display a value, or unknown if the device was out of reach. Instead, it seems to keep the last known value.

Initially, I wanted to use these to determine whether both person entities where not at home. This is usually done via phone, but when going for a walk or somewhere close, we (or one person) might leave the phone(s) at home and therefore not reliably report the actual status (just the abandoned phone’s status). The bands are usually worn all day, so even when leaving the phone, we would be out of reach of both ESPhomes and therefore likely not at home.

But then I thought it’d be cool to create actions like, if

  • both mibands are likely in the bedroom for 10 minutes
  • sun is down
  • bedroom door is closed

then

  • turn off downstairs light
  • lower temperature of downstairs climate entities
  • etc.

But this might be difficult if someitmes the downstairs office sensors are not unknown or unavailable even though they should be (and usually are; for example, while typing this, the downstairs office miband_5 has eventually changed to unknown, but I don’t know what caused this as I haven’t moved at all). Also, the upstairs bedroom miband_3 is still unknown even though it has also not been moved and was previously at around -78 db.

Do you use BT tracking in some (but not all) rooms and does it work reliably? Thank you for your input :slight_smile: