ESPHome 2025.12.0-dev
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,
19 ETRAILER = 0x46,
20};
21
22// 4 values in one struct so it aligns to 8 byte. One `mopeka_std_values` is 40 bit long.
23struct mopeka_std_values { // NOLINT(readability-identifier-naming,altera-struct-pack-align)
24 u_int16_t time_0 : 5;
25 u_int16_t value_0 : 5;
26 u_int16_t time_1 : 5;
27 u_int16_t value_1 : 5;
28 u_int16_t time_2 : 5;
29 u_int16_t value_2 : 5;
30 u_int16_t time_3 : 5;
31 u_int16_t value_3 : 5;
32} __attribute__((packed));
33
34struct mopeka_std_package { // NOLINT(readability-identifier-naming,altera-struct-pack-align)
35 u_int8_t data_0 : 8;
36 u_int8_t data_1 : 8;
37 u_int8_t raw_voltage : 8;
38
39 u_int8_t raw_temp : 6;
41 bool sync_pressed : 1;
42
44} __attribute__((packed));
45
47 public:
48 void set_address(uint64_t address) { address_ = address; };
49
50 bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
51 void dump_config() override;
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
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:42
const char * message
Definition component.cpp:38
mopeka_std_values val[4]
esphome::mopeka_std_check::MopekaStdCheck __attribute__
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t temperature
Definition sun_gtil2.cpp:12