ESPHome  2024.11.2
mopeka_pro_check.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cinttypes>
4 #include <vector>
5 
9 
10 #ifdef USE_ESP32
11 
12 namespace esphome {
13 namespace mopeka_pro_check {
14 
15 enum SensorType {
21  PRO_UNIVERSAL = 0xC // Pro Check Universal
22 
23  // all other values are reserved
24 };
25 
26 // Sensor read quality. If sensor is poorly placed or tank level
27 // gets too low the read quality will show and the distance
28 // measurement may be inaccurate.
30 
32  public:
33  void set_address(uint64_t address) { address_ = address; };
34 
35  bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
36  void dump_config() override;
37  float get_setup_priority() const override { return setup_priority::DATA; }
39 
40  void set_level(sensor::Sensor *level) { level_ = level; };
43  void set_distance(sensor::Sensor *distance) { distance_ = distance; };
46  void set_tank_full(float full) { full_mm_ = full; };
47  void set_tank_empty(float empty) { empty_mm_ = empty; };
48 
49  protected:
50  uint64_t address_;
57 
58  uint32_t full_mm_;
59  uint32_t empty_mm_;
60  uint32_t ignored_read_count_ = 0;
62 
63  uint8_t parse_battery_level_(const std::vector<uint8_t> &message);
64  uint32_t parse_distance_(const std::vector<uint8_t> &message);
65  uint8_t parse_temperature_(const std::vector<uint8_t> &message);
66  SensorReadQuality parse_read_quality_(const std::vector<uint8_t> &message);
67 };
68 
69 } // namespace mopeka_pro_check
70 } // namespace esphome
71 
72 #endif
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void set_level(sensor::Sensor *level)
void set_distance(sensor::Sensor *distance)
void set_ignored_reads(sensor::Sensor *ir)
SensorReadQuality parse_read_quality_(const std::vector< uint8_t > &message)
uint32_t parse_distance_(const std::vector< uint8_t > &message)
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override
Main parse function that gets called for all ble advertisements.
void set_battery_level(sensor::Sensor *bat)
uint8_t parse_battery_level_(const std::vector< uint8_t > &message)
void set_temperature(sensor::Sensor *temperature)
uint16_t temperature
Definition: sun_gtil2.cpp:26
void set_min_signal_quality(SensorReadQuality min)
uint8_t parse_temperature_(const std::vector< uint8_t > &message)
void set_signal_quality(sensor::Sensor *rq)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
uint8_t address
Definition: bl0906.h:211
Base-class for all sensors.
Definition: sensor.h:57