esphome/wohnzimmer_ble_tracker.yaml

50 lines
1.1 KiB
YAML
Raw Normal View History

esphome:
name: wohnzimmer-ble-tracker
includes:
- my_btmonitor.h
libraries:
- mbedtls
esp32:
board: m5stack-atom
framework:
type: arduino
logger:
ota:
password: !secret ota_password
wifi:
ssid: WLAN
password: !secret wifi_password
mqtt:
broker: homeassistant.fritz.box
username: !secret mqtt_ble_username
password: !secret mqtt_ble_password
discovery: false
esp32_ble_tracker:
scan_parameters:
interval: 1.2s
window: 500ms
active: false
on_ble_advertise:
- then:
- lambda: |-
const char * detected_device_name = ble_device_name(x.address());
if(detected_device_name != nullptr) {
auto build_json = [&](JsonObject obj) {
obj["id"] = detected_device_name;
obj["rssi"] = x.get_rssi();
if(x.get_tx_powers().size() > 0)
obj["tx_power"] = x.get_tx_powers()[0];
};
global_mqtt_client->publish_json(std::string("my_btmonitor/devices/") + detected_device_name + "/wohnzimmer",
build_json);
}