esphome/components/esp32_nimble_mqtt_room/esp32_nimble_mqtt_room.cpp
2023-12-03 22:19:57 +03:00

20 lines
644 B
C++

#include "esp32_nimble_mqtt_room.h"
namespace esphome
{
namespace esp32_nimble_mqtt_room
{
void ESP32NimbleMQTTRoom::on_result(nimble_distance_custom::NimbleDistanceCustomResult& result)
{
auto address = result.address.toString();
this->publish_json(
this->base_topic_ + "/devices/" + address + "/" + this->room_,
[=](ArduinoJson::JsonObject root) -> void {
root["id"] = address;
root["distance"] = result.distance;
}
);
};
} // namespace esp32_nimble_tracker
} // namespace esphome