ESPHome  2024.4.0
ble_scanner.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ctime>
4 #include <string>
5 
9 
10 #ifdef USE_ESP32
11 
12 namespace esphome {
13 namespace ble_scanner {
14 
16  public:
17  bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override {
18  this->publish_state("{\"timestamp\":" + to_string(::time(nullptr)) +
19  ","
20  "\"address\":\"" +
21  device.address_str() +
22  "\","
23  "\"rssi\":" +
24  to_string(device.get_rssi()) +
25  ","
26  "\"name\":\"" +
27  device.get_name() + "\"}");
28 
29  return true;
30  }
31  void dump_config() override;
32  float get_setup_priority() const override { return setup_priority::DATA; }
33 };
34 
35 } // namespace ble_scanner
36 } // namespace esphome
37 
38 #endif
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void publish_state(const std::string &state)
Definition: text_sensor.cpp:9
float get_setup_priority() const override
Definition: ble_scanner.h:32
std::string to_string(int value)
Definition: helpers.cpp:82
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
const std::string & get_name() const
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override
Definition: ble_scanner.h:17