ESPHome  2024.11.0
xiaomi_miscale.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 #include <vector>
8 
9 #ifdef USE_ESP32
10 
11 namespace esphome {
12 namespace xiaomi_miscale {
13 
14 struct ParseResult {
15  int version;
18 };
19 
21  public:
22  void set_address(uint64_t address) { address_ = address; };
23 
24  bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
25  void dump_config() override;
26  float get_setup_priority() const override { return setup_priority::DATA; }
27  void set_weight(sensor::Sensor *weight) { weight_ = weight; }
29  void set_clear_impedance(bool clear_impedance) { clear_impedance_ = clear_impedance; }
30 
31  protected:
32  uint64_t address_;
33  sensor::Sensor *weight_{nullptr};
34  sensor::Sensor *impedance_{nullptr};
35  bool clear_impedance_{false};
36 
37  optional<ParseResult> parse_header_(const esp32_ble_tracker::ServiceData &service_data);
38  bool parse_message_(const std::vector<uint8_t> &message, ParseResult &result);
39  bool parse_message_v1_(const std::vector<uint8_t> &message, ParseResult &result);
40  bool parse_message_v2_(const std::vector<uint8_t> &message, ParseResult &result);
41  bool report_results_(const optional<ParseResult> &result, const std::string &address);
42 };
43 
44 } // namespace xiaomi_miscale
45 } // namespace esphome
46 
47 #endif
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void set_clear_impedance(bool clear_impedance)
void set_weight(sensor::Sensor *weight)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint8_t address
Definition: bl0906.h:211
float get_setup_priority() const override
Base-class for all sensors.
Definition: sensor.h:57
void set_impedance(sensor::Sensor *impedance)