-
Install “crownstone” application on your iPhone
- When running after installation, the ble overflow area is fixed.
http://www.davidgyoungtech.com/2020/05/07/hacking-the-overflow-area - When you boot up your smartphone, you need to run the application.
- The room-assistant app also works, but all devices send the same signal.
- When running after installation, the ble overflow area is fixed.
-
Coding ESPHome to detect iPhone
esphome:
name: livingroom-ble-tracker
platform: ESP32
board: esp32dev
arduino_version: dev
# Enable logging
logger:
#level: very_verbose
# Enable Home Assistant API
api:
ota:
wifi:
ssid: "xxxxx"
password: "xxxxx"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Livingroom-Ble-Tracker"
captive_portal:
esp32_ble_tracker:
scan_parameters:
interval: 1s
window: 1s
duration: 30s
on_ble_advertise:
- then:
- lambda: |-
bool user1_livingroom_ble_status = false;
bool user2_livingroom_ble_status = false;
for (auto data : x.get_manufacturer_datas()) {
if (strcmp(hexencode(data.data).c_str(), "01.00.00.00.10.00.00.00.00.00.00.00.00.00.00.00.00 (17)") == 0) {
if (x.get_rssi() > -81){
ESP_LOGD("ble_adv", "user1 found in livingroom");
user1_livingroom_ble_status = true;
}
}
else if (strcmp(hexencode(data.data).c_str(), "01.00.00.00.xx.00.00.00.00.00.00.00.00.00.00.00.00 (17)") == 0) {
if (x.get_rssi() > -81){
ESP_LOGD("ble_adv", "user2 found in livingroom!");
user2_livingroom_ble_status = true;
}
}
ESP_LOGD("ble_adv", " - %s", hexencode(data.data).c_str());
}
id(user1_livingroom_ble).publish_state(user1_livingroom_ble_status);
id(user2_livingroom_ble).publish_state(user2_livingroom_ble_status);
binary_sensor:
- platform: template
device_class: presence
name: "user1_livingroom_ble"
id: user1_livingroom_ble
filters:
- delayed_off: 30s
- platform: template
device_class: presence
name: "user2_livingroom_ble"
id: user2_livingroom_ble
filters:
- delayed_off: 30s
- After the first run, find a string similar to
“01.00.00.00.10.00.00.00.00.00.00.00.00.00.00.00.00 (17)”
and change it in the code
(starts with “01” and ends with “(17)”)