Added support for MQTT Room Presence
What does this implement/fix?
This implements a new component that track BLE devices and send the distance using MQTT to Home Assistant for the MQTT Room Presence sensor.
Types of changes
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Other
Related issue or feature (if applicable): https://github.com/esphome/feature-requests/issues/1412
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#2257
Test Environment
- [x] ESP32
- [ ] ESP32 IDF
- [ ] ESP8266
Example entry for config.yaml:
# Example config.yaml
esp32_ble_tracker:
scan_parameters:
duration: 30s
sensor:
- platform: ble_rssi
ibeacon_uuid: '11223344-5566-7788-99aa-bbccddeeff00'
id: my_own_tracker
mqtt_room:
room: Living Room
trackers:
- device_id: my_own_tracker
name: My own tracker
Checklist:
- [x] The code change is tested and works locally.
- [x] Tests have been added to verify that the new code works (under
tests/folder).
If user exposed functionality or configuration variables are added/changed:
- [x] Documentation added/updated in esphome-docs.
I also wouldn't close the linked issue when this is merged, the big draw of the ESPresense project is 1. filtering so that distance isn't extremely noisy and 2. fingerprinting apple devices that don't have set uuids. This is a great PR but it fixes a different, though related, problem.
I'm currently working on getting the fingerprinting working and tx power. But I won't be able to test the fingerprinting for Apple devices because I don't own any.
I have changed how trackers are detected so there are some changes in the config.yaml
# Example config.yaml
esp32_ble_tracker:
scan_parameters:
duration: 30s
mqtt_room:
room: Living Room
I'm currently working on getting the fingerprinting working and tx power. But I won't be able to test the fingerprinting for Apple devices because I don't own any.
Awesome! Is this sensor compatible with the ESPHome built in sensor filtering capabilities? If so, that would probably suffice, instead of adding the one euro filter or doing the median in this component.
I'm currently working on getting the fingerprinting working and tx power. But I won't be able to test the fingerprinting for Apple devices because I don't own any.
Awesome! Is this sensor compatible with the ESPHome built in sensor filtering capabilities? If so, that would probably suffice, instead of adding the one euro filter or doing the median in this component.
Currently not, but that is a thing I want to implement soon.
I have added support for sensor filters and custom signal power. The filters will also be used in the calculation that is send using MQTT Room Presence.
mqtt_room:
room: Living Room
state_topic: esphome/rooms # Optional
trackers:
- device_id: ibeacon:11223344-5566-7788-99aa-bbccddeeff00-1-100
name: Personal Tracker # Optional
signal_power: -72 # Optional
rssi: # Optional
name: Tracker RSSI
distance: # Optional
name: Distance RSSI
Coincidentally I’m working on something similar here https://github.com/mvgijssel/setup/pull/128, where I’m creating a ble distance component based on ESPresence logic.
The default Bluetooth stack of ESPHome (Bluedroid) which is used by esp32_ble_tracker currently does not support tracking Apple devices using irks, therefore I’m using the NimBLE stack instead.
If we manage to get NimBLE support in ESPHome then integration with this component means all the same functionality related to device tracking from ESPresence would be available to everyone!
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.
@wjtje @jesserockz what's needed to get this merged? There was some good work done that would be nice to have in esphome.
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.
@wjtje @jesserockz bumping again
@mvgijssel may have some input here as well since they were working on something similar.
Would love to have this integrated into esphome.
This seems to be crashing a lot here:
[16:12:51][D][mqtt_room:096]: device '11:22:33:44:55:66': fetching manufacturer data
[16:12:51][D][mqtt_room:125]: Found device with id: 'ibeacon:92A41396-87FA-A499-214E-EAD9B75C7650-64052-27623'
[16:12:51]
[16:12:51]Stack smashing protect failure!
[16:12:51]
[16:12:51]
[16:12:51]abort() was called at PC 0x400f9c5b on core 1
[16:12:51]
[16:12:51]
[16:12:51]Backtrace:0x40083c59:0x3ffcd4b00x40093529:0x3ffcd4d0 0x40098aed:0x3ffcd4f0 0x400f9c5b:0x3ffcd570 0x400e2f45:0x3ffcd590 0x400e2f81:0x3ffcd660 0x400d9de5:0x3ffcd680 0x401fd8ad:0x3ffcd790 0x401fd961:0x3ffcd7b0 0x400e7d96:0x3ffcd7d0 0x400ea90a:0x3ffcd800 0x400f0f52:0x3ffcd8e0
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x40083c59: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
WARNING Decoded 0x40093529: esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
WARNING Decoded 0x40098aed: abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46
WARNING Decoded 0x400f9c5b: __stack_chk_fail at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/stack_check.c:36
WARNING Decoded 0x400e2f45: esphome::mqtt_room::MqttRoom::parse_device(esphome::esp32_ble_tracker::ESPBTDevice const&) at /config/.esphome/build/m5atom-desktop/src/esphome/components/mqtt_room/mqtt_room.cpp:138
WARNING Decoded 0x400e2f81: non-virtual thunk to esphome::mqtt_room::MqttRoom::parse_device(esphome::esp32_ble_tracker::ESPBTDevice const&)
WARNING Decoded 0x400d9de5: esphome::esp32_ble_tracker::ESP32BLETracker::loop() at /config/.esphome/build/m5atom-desktop/src/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp:127 (discriminator 2)
WARNING Decoded 0x401fd8ad: esphome::Component::call_loop() at /config/.esphome/build/m5atom-desktop/src/esphome/core/component.cpp:76
WARNING Decoded 0x401fd961: esphome::Component::call() at /config/.esphome/build/m5atom-desktop/src/esphome/core/component.cpp:98
WARNING Decoded 0x400e7d96: esphome::Application::setup() at /config/.esphome/build/m5atom-desktop/src/esphome/core/application.cpp:52 (discriminator 2)
WARNING Decoded 0x400ea90a: setup() at /config/.esphome/build/m5atom-desktop/src/main.cpp:393
WARNING Decoded 0x400f0f52: loopTask(void*) at /config/.esphome/platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42
Sometimes it finds a few more devices, but crashes in the end. Any suggestions how to debug this?
I have changed to format device name function, hopefully this is better. It seemed like I allocated to much room for the new string.
I don't think it was device name, I still get crashes. Checking if some device is non-compliant with the spec (?) and requires bigger buffers.
UPD: bumping buffer for ibeacon: string to 128 chars seems to help
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.
Still current.