ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
ezo_pmp.h
Go to the documentation of this file.
1#pragma once
2
6
7#ifdef USE_BINARY_SENSOR
9#endif
10
11#ifdef USE_SENSOR
13#endif
14
15#ifdef USE_TEXT_SENSOR
17#endif
18
19namespace esphome::ezo_pmp {
20
21class EzoPMP final : public PollingComponent, public i2c::I2CDevice {
22 public:
23 void dump_config() override;
24
25 void loop() override;
26 void update() override;
27
28#ifdef USE_SENSOR
29 void set_current_volume_dosed(sensor::Sensor *current_volume_dosed) { current_volume_dosed_ = current_volume_dosed; }
30 void set_total_volume_dosed(sensor::Sensor *total_volume_dosed) { total_volume_dosed_ = total_volume_dosed; }
31 void set_absolute_total_volume_dosed(sensor::Sensor *absolute_total_volume_dosed) {
32 absolute_total_volume_dosed_ = absolute_total_volume_dosed;
33 }
34 void set_pump_voltage(sensor::Sensor *pump_voltage) { pump_voltage_ = pump_voltage; }
35 void set_last_volume_requested(sensor::Sensor *last_volume_requested) {
36 last_volume_requested_ = last_volume_requested;
37 }
38 void set_max_flow_rate(sensor::Sensor *max_flow_rate) { max_flow_rate_ = max_flow_rate; }
39#endif
40
41#ifdef USE_BINARY_SENSOR
42 void set_is_dosing(binary_sensor::BinarySensor *is_dosing) { is_dosing_ = is_dosing; }
43 void set_is_paused(binary_sensor::BinarySensor *is_paused) { is_paused_ = is_paused; }
44#endif
45
46#ifdef USE_TEXT_SENSOR
47 void set_dosing_mode(text_sensor::TextSensor *dosing_mode) { dosing_mode_ = dosing_mode; }
48 void set_calibration_status(text_sensor::TextSensor *calibration_status) { calibration_status_ = calibration_status; }
49#endif
50
51 // Actions for EZO-PMP
52 void find();
53 void dose_continuously();
54 void dose_volume(double volume);
55 void dose_volume_over_time(double volume, int duration);
56 void dose_with_constant_flow_rate(double volume, int duration);
57 void set_calibration_volume(double volume);
59 void clear_calibration();
60 void pause_dosing();
61 void stop_dosing();
63 void exec_arbitrary_command(const std::basic_string<char> &command);
64
65 protected:
68 bool is_waiting_ = false;
69 bool is_first_read_ = true;
70
71 uint16_t next_command_ = 0;
72 double next_command_volume_ = 0; // might be negative
74
75 uint16_t next_command_queue_[10];
81
82 uint16_t current_command_ = 0;
83 bool is_paused_flag_ = false;
84 bool is_dosing_flag_ = false;
85
86 std::string arbitrary_command_{};
87
88 void send_next_command_();
91 void queue_command_(uint16_t command, double volume, int duration, bool should_schedule);
92 void pop_next_command_();
93 uint16_t peek_next_command_();
94
95#ifdef USE_SENSOR
102#endif
103
104#ifdef USE_BINARY_SENSOR
107#endif
108
109#ifdef USE_TEXT_SENSOR
112#endif
113};
114
115} // namespace esphome::ezo_pmp
uint8_t address
Definition bl0906.h:4
This class simplifies creating components that periodically check a state.
Definition component.h:519
Base class for all binary_sensor-type classes.
sensor::Sensor * total_volume_dosed_
Definition ezo_pmp.h:97
void exec_arbitrary_command(const std::basic_string< char > &command)
Definition ezo_pmp.cpp:589
void dose_volume(double volume)
Definition ezo_pmp.cpp:535
uint16_t current_command_
Definition ezo_pmp.h:82
void set_is_paused(binary_sensor::BinarySensor *is_paused)
Definition ezo_pmp.h:43
binary_sensor::BinarySensor * is_paused_
Definition ezo_pmp.h:106
int next_command_duration_queue_[10]
Definition ezo_pmp.h:77
void set_current_volume_dosed(sensor::Sensor *current_volume_dosed)
Definition ezo_pmp.h:29
sensor::Sensor * max_flow_rate_
Definition ezo_pmp.h:100
void set_pump_voltage(sensor::Sensor *pump_voltage)
Definition ezo_pmp.h:34
void set_dosing_mode(text_sensor::TextSensor *dosing_mode)
Definition ezo_pmp.h:47
uint16_t next_command_queue_[10]
Definition ezo_pmp.h:75
std::string arbitrary_command_
Definition ezo_pmp.h:86
void dump_config() override
Definition ezo_pmp.cpp:40
void set_max_flow_rate(sensor::Sensor *max_flow_rate)
Definition ezo_pmp.h:38
double next_command_volume_queue_[10]
Definition ezo_pmp.h:76
void set_calibration_volume(double volume)
Definition ezo_pmp.cpp:559
void set_absolute_total_volume_dosed(sensor::Sensor *absolute_total_volume_dosed)
Definition ezo_pmp.h:31
void set_total_volume_dosed(sensor::Sensor *total_volume_dosed)
Definition ezo_pmp.h:30
void set_calibration_status(text_sensor::TextSensor *calibration_status)
Definition ezo_pmp.h:48
void change_i2c_address(int address)
Definition ezo_pmp.cpp:585
void queue_command_(uint16_t command, double volume, int duration, bool should_schedule)
Definition ezo_pmp.cpp:498
void loop() override
Definition ezo_pmp.cpp:83
binary_sensor::BinarySensor * is_dosing_
Definition ezo_pmp.h:105
sensor::Sensor * last_volume_requested_
Definition ezo_pmp.h:101
void set_is_dosing(binary_sensor::BinarySensor *is_dosing)
Definition ezo_pmp.h:42
void dose_volume_over_time(double volume, int duration)
Definition ezo_pmp.cpp:543
void set_last_volume_requested(sensor::Sensor *last_volume_requested)
Definition ezo_pmp.h:35
uint16_t peek_next_command_()
Definition ezo_pmp.cpp:490
sensor::Sensor * absolute_total_volume_dosed_
Definition ezo_pmp.h:98
text_sensor::TextSensor * dosing_mode_
Definition ezo_pmp.h:110
sensor::Sensor * pump_voltage_
Definition ezo_pmp.h:99
sensor::Sensor * current_volume_dosed_
Definition ezo_pmp.h:96
void dose_with_constant_flow_rate(double volume, int duration)
Definition ezo_pmp.cpp:551
void update() override
Definition ezo_pmp.cpp:45
text_sensor::TextSensor * calibration_status_
Definition ezo_pmp.h:111
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
Base-class for all sensors.
Definition sensor.h:47
uint8_t duration
Definition msa3xx.h:0
static void uint32_t