ESPHome 2025.5.0
Loading...
Searching...
No Matches
mopeka_std_check.h
Go to the documentation of this file.
1#pragma once
3#include <cinttypes>
4#include <vector>
9
10#ifdef USE_ESP32
11
12namespace esphome {
13namespace mopeka_std_check {
14
16 STANDARD = 0x02,
17 XL = 0x03,
18 ETRAILER = 0x46,
19};
20
21// 4 values in one struct so it aligns to 8 byte. One `mopeka_std_values` is 40 bit long.
22struct mopeka_std_values { // NOLINT(readability-identifier-naming,altera-struct-pack-align)
23 u_int16_t time_0 : 5;
24 u_int16_t value_0 : 5;
25 u_int16_t time_1 : 5;
26 u_int16_t value_1 : 5;
27 u_int16_t time_2 : 5;
28 u_int16_t value_2 : 5;
29 u_int16_t time_3 : 5;
30 u_int16_t value_3 : 5;
31} __attribute__((packed));
32
33struct mopeka_std_package { // NOLINT(readability-identifier-naming,altera-struct-pack-align)
34 u_int8_t data_0 : 8;
35 u_int8_t data_1 : 8;
36 u_int8_t raw_voltage : 8;
37
38 u_int8_t raw_temp : 6;
40 bool sync_pressed : 1;
41
43} __attribute__((packed));
44
46 public:
47 void set_address(uint64_t address) { address_ = address; };
48
49 bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
50 void dump_config() override;
51 float get_setup_priority() const override { return setup_priority::DATA; }
52
53 void set_level(sensor::Sensor *level) { this->level_ = level; };
55 void set_battery_level(sensor::Sensor *bat) { this->battery_level_ = bat; };
56 void set_distance(sensor::Sensor *distance) { this->distance_ = distance; };
58 void set_tank_full(float full) { this->full_mm_ = full; };
59 void set_tank_empty(float empty) { this->empty_mm_ = empty; };
60
61 protected:
62 uint64_t address_;
67
69 uint32_t full_mm_;
70 uint32_t empty_mm_;
71
73 uint8_t parse_battery_level_(const mopeka_std_package *message);
74 uint8_t parse_temperature_(const mopeka_std_package *message);
75};
76
77} // namespace mopeka_std_check
78} // namespace esphome
79
80#endif
uint8_t address
Definition bl0906.h:4
void set_distance(sensor::Sensor *distance)
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override
Main parse function that gets called for all ble advertisements.
void set_temperature(sensor::Sensor *temperature)
uint8_t parse_temperature_(const mopeka_std_package *message)
uint8_t parse_battery_level_(const mopeka_std_package *message)
void set_battery_level(sensor::Sensor *bat)
Base-class for all sensors.
Definition sensor.h:57
mopeka_std_values val[4]
esphome::mopeka_std_check::MopekaStdCheck __attribute__
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t temperature
Definition sun_gtil2.cpp:12