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