ESPHome 2026.1.4
Loading...
Searching...
No Matches
ezo_pmp.cpp
Go to the documentation of this file.
1#include "ezo_pmp.h"
2#include "esphome/core/log.h"
3#include "esphome/core/hal.h"
4
5namespace esphome {
6namespace ezo_pmp {
7
8static const char *const TAG = "ezo-pmp";
9
10static const uint16_t EZO_PMP_COMMAND_NONE = 0;
11static const uint16_t EZO_PMP_COMMAND_TYPE_READ = 1;
12
13static const uint16_t EZO_PMP_COMMAND_FIND = 2;
14static const uint16_t EZO_PMP_COMMAND_DOSE_CONTINUOUSLY = 4;
15static const uint16_t EZO_PMP_COMMAND_DOSE_VOLUME = 8;
16static const uint16_t EZO_PMP_COMMAND_DOSE_VOLUME_OVER_TIME = 16;
17static const uint16_t EZO_PMP_COMMAND_DOSE_WITH_CONSTANT_FLOW_RATE = 32;
18static const uint16_t EZO_PMP_COMMAND_SET_CALIBRATION_VOLUME = 64;
19static const uint16_t EZO_PMP_COMMAND_CLEAR_TOTAL_VOLUME_DOSED = 128;
20static const uint16_t EZO_PMP_COMMAND_CLEAR_CALIBRATION = 256;
21static const uint16_t EZO_PMP_COMMAND_PAUSE_DOSING = 512;
22static const uint16_t EZO_PMP_COMMAND_STOP_DOSING = 1024;
23static const uint16_t EZO_PMP_COMMAND_CHANGE_I2C_ADDRESS = 2048;
24static const uint16_t EZO_PMP_COMMAND_EXEC_ARBITRARY_COMMAND_ADDRESS = 4096;
25
26static const uint16_t EZO_PMP_COMMAND_READ_DOSING = 3;
27static const uint16_t EZO_PMP_COMMAND_READ_SINGLE_REPORT = 5;
28static const uint16_t EZO_PMP_COMMAND_READ_MAX_FLOW_RATE = 9;
29static const uint16_t EZO_PMP_COMMAND_READ_PAUSE_STATUS = 17;
30static const uint16_t EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED = 33;
31static const uint16_t EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED = 65;
32static const uint16_t EZO_PMP_COMMAND_READ_CALIBRATION_STATUS = 129;
33static const uint16_t EZO_PMP_COMMAND_READ_PUMP_VOLTAGE = 257;
34
35static const std::string DOSING_MODE_NONE = "None";
36static const std::string DOSING_MODE_VOLUME = "Volume";
37static const std::string DOSING_MODE_VOLUME_OVER_TIME = "Volume/Time";
38static const std::string DOSING_MODE_CONSTANT_FLOW_RATE = "Constant Flow Rate";
39static const std::string DOSING_MODE_CONTINUOUS = "Continuous";
40
42 LOG_I2C_DEVICE(this);
43 if (this->is_failed()) {
44 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
45 }
46 LOG_UPDATE_INTERVAL(this);
47}
48
50 if (this->is_waiting_) {
51 return;
52 }
53
54 if (this->is_first_read_) {
55 this->queue_command_(EZO_PMP_COMMAND_READ_CALIBRATION_STATUS, 0, 0, (bool) this->calibration_status_);
56 this->queue_command_(EZO_PMP_COMMAND_READ_MAX_FLOW_RATE, 0, 0, (bool) this->max_flow_rate_);
57 this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
58 this->queue_command_(EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED, 0, 0, (bool) this->total_volume_dosed_);
59 this->queue_command_(EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED, 0, 0,
60 (bool) this->absolute_total_volume_dosed_);
61 this->queue_command_(EZO_PMP_COMMAND_READ_PAUSE_STATUS, 0, 0, true);
62 this->is_first_read_ = false;
63 }
64
65 if (!this->is_waiting_ && this->peek_next_command_() == EZO_PMP_COMMAND_NONE) {
66 this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
67
68 if (this->is_dosing_flag_) {
69 this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
70 this->queue_command_(EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED, 0, 0, (bool) this->total_volume_dosed_);
71 this->queue_command_(EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED, 0, 0,
72 (bool) this->absolute_total_volume_dosed_);
73 }
74
75 this->queue_command_(EZO_PMP_COMMAND_READ_PUMP_VOLTAGE, 0, 0, (bool) this->pump_voltage_);
76 } else {
77 ESP_LOGV(TAG, "Not Scheduling new Command during update()");
78 }
79}
80
82 // If we are not waiting for anything and there is no command to be sent, return
83 if (!this->is_waiting_ && this->peek_next_command_() == EZO_PMP_COMMAND_NONE) {
84 return;
85 }
86
87 // If we are not waiting for anything and there IS a command to be sent, do it.
88 if (!this->is_waiting_ && this->peek_next_command_() != EZO_PMP_COMMAND_NONE) {
89 this->send_next_command_();
90 }
91
92 // If we are waiting for something but it isn't ready yet, then return
93 if (this->is_waiting_ && millis() - this->start_time_ < this->wait_time_) {
94 return;
95 }
96
97 // We are waiting for something and it should be ready.
99}
100
102 this->current_command_ = EZO_PMP_COMMAND_NONE;
103 this->is_waiting_ = false;
104}
105
107 uint8_t response_buffer[21] = {'\0'};
108
109 response_buffer[0] = 0;
110 if (!this->read_bytes_raw(response_buffer, 20)) {
111 ESP_LOGE(TAG, "read error");
113 return;
114 }
115
116 switch (response_buffer[0]) {
117 case 254:
118 return; // keep waiting
119 case 1:
120 break;
121 case 2:
122 ESP_LOGE(TAG, "device returned a syntax error");
124 return;
125 case 255:
126 ESP_LOGE(TAG, "device returned no data");
128 return;
129 default:
130 ESP_LOGE(TAG, "device returned an unknown response: %d", response_buffer[0]);
132 return;
133 }
134
135 char first_parameter_buffer[10] = {'\0'};
136 char second_parameter_buffer[10] = {'\0'};
137 char third_parameter_buffer[10] = {'\0'};
138
139 first_parameter_buffer[0] = '\0';
140 second_parameter_buffer[0] = '\0';
141 third_parameter_buffer[0] = '\0';
142
143 int current_parameter = 1;
144
145 size_t position_in_parameter_buffer = 0;
146 // some sensors return multiple comma-separated values, terminate string after first one
147 for (size_t i = 1; i < sizeof(response_buffer) - 1; i++) {
148 char current_char = response_buffer[i];
149
150 if (current_char == '\0') {
151 ESP_LOGV(TAG,
152 "Read Response from device: %s\n"
153 "First Component: %s\n"
154 "Second Component: %s\n"
155 "Third Component: %s",
156 (char *) response_buffer, (char *) first_parameter_buffer, (char *) second_parameter_buffer,
157 (char *) third_parameter_buffer);
158
159 break;
160 }
161
162 if (current_char == ',') {
163 current_parameter++;
164 position_in_parameter_buffer = 0;
165 continue;
166 }
167
168 switch (current_parameter) {
169 case 1:
170 first_parameter_buffer[position_in_parameter_buffer] = current_char;
171 first_parameter_buffer[position_in_parameter_buffer + 1] = '\0';
172 break;
173 case 2:
174 second_parameter_buffer[position_in_parameter_buffer] = current_char;
175 second_parameter_buffer[position_in_parameter_buffer + 1] = '\0';
176 break;
177 case 3:
178 third_parameter_buffer[position_in_parameter_buffer] = current_char;
179 third_parameter_buffer[position_in_parameter_buffer + 1] = '\0';
180 break;
181 }
182
183 position_in_parameter_buffer++;
184 }
185
186 auto parsed_first_parameter = parse_number<float>(first_parameter_buffer);
187 auto parsed_second_parameter = parse_number<float>(second_parameter_buffer);
188 auto parsed_third_parameter = parse_number<float>(third_parameter_buffer);
189
190 switch (this->current_command_) {
191 // Read Commands
192 case EZO_PMP_COMMAND_READ_DOSING: // Page 54
193 if (parsed_third_parameter.has_value())
194 this->is_dosing_flag_ = parsed_third_parameter.value_or(0) == 1;
195
196 if (this->is_dosing_)
198
199 if (parsed_second_parameter.has_value() && this->last_volume_requested_) {
200 this->last_volume_requested_->publish_state(parsed_second_parameter.value_or(0));
201 }
202
203 if (!this->is_dosing_flag_ && !this->is_paused_flag_) {
204 // If pump is not paused and not dispensing
205 if (this->dosing_mode_ && this->dosing_mode_->state != DOSING_MODE_NONE)
206 this->dosing_mode_->publish_state(DOSING_MODE_NONE);
207 }
208
209 break;
210
211 case EZO_PMP_COMMAND_READ_SINGLE_REPORT: // Single Report (page 53)
212 if (parsed_first_parameter.has_value() && (bool) this->current_volume_dosed_) {
213 this->current_volume_dosed_->publish_state(parsed_first_parameter.value_or(0));
214 }
215 break;
216
217 case EZO_PMP_COMMAND_READ_MAX_FLOW_RATE: // Constant Flow Rate (page 57)
218 if (parsed_second_parameter.has_value() && this->max_flow_rate_)
219 this->max_flow_rate_->publish_state(parsed_second_parameter.value_or(0));
220 break;
221
222 case EZO_PMP_COMMAND_READ_PAUSE_STATUS: // Pause (page 61)
223 if (parsed_second_parameter.has_value())
224 this->is_paused_flag_ = parsed_second_parameter.value_or(0) == 1;
225
226 if (this->is_paused_)
228 break;
229
230 case EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED: // Total Volume Dispensed (page 64)
231 if (parsed_second_parameter.has_value() && this->total_volume_dosed_)
232 this->total_volume_dosed_->publish_state(parsed_second_parameter.value_or(0));
233 break;
234
235 case EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED: // Total Volume Dispensed (page 64)
236 if (parsed_second_parameter.has_value() && this->absolute_total_volume_dosed_)
237 this->absolute_total_volume_dosed_->publish_state(parsed_second_parameter.value_or(0));
238 break;
239
240 case EZO_PMP_COMMAND_READ_CALIBRATION_STATUS: // Calibration (page 65)
241 if (parsed_second_parameter.has_value() && this->calibration_status_) {
242 if (parsed_second_parameter.value_or(0) == 1) {
243 this->calibration_status_->publish_state("Fixed Volume");
244 } else if (parsed_second_parameter.value_or(0) == 2) {
245 this->calibration_status_->publish_state("Volume/Time");
246 } else if (parsed_second_parameter.value_or(0) == 3) {
247 this->calibration_status_->publish_state("Fixed Volume & Volume/Time");
248 } else {
249 this->calibration_status_->publish_state("Uncalibrated");
250 }
251 }
252 break;
253
254 case EZO_PMP_COMMAND_READ_PUMP_VOLTAGE: // Pump Voltage (page 67)
255 if (parsed_second_parameter.has_value() && this->pump_voltage_)
256 this->pump_voltage_->publish_state(parsed_second_parameter.value_or(0));
257 break;
258
259 // Non-Read Commands
260
261 case EZO_PMP_COMMAND_DOSE_VOLUME: // Volume Dispensing (page 55)
262 if (this->dosing_mode_ && this->dosing_mode_->state != DOSING_MODE_VOLUME)
263 this->dosing_mode_->publish_state(DOSING_MODE_VOLUME);
264 break;
265
266 case EZO_PMP_COMMAND_DOSE_VOLUME_OVER_TIME: // Dose over time (page 56)
267 if (this->dosing_mode_ && this->dosing_mode_->state != DOSING_MODE_VOLUME_OVER_TIME)
268 this->dosing_mode_->publish_state(DOSING_MODE_VOLUME_OVER_TIME);
269 break;
270
271 case EZO_PMP_COMMAND_DOSE_WITH_CONSTANT_FLOW_RATE: // Constant Flow Rate (page 57)
272 if (this->dosing_mode_ && this->dosing_mode_->state != DOSING_MODE_CONSTANT_FLOW_RATE)
273 this->dosing_mode_->publish_state(DOSING_MODE_CONSTANT_FLOW_RATE);
274 break;
275
276 case EZO_PMP_COMMAND_DOSE_CONTINUOUSLY: // Continuous Dispensing (page 54)
277 if (this->dosing_mode_ && this->dosing_mode_->state != DOSING_MODE_CONTINUOUS)
278 this->dosing_mode_->publish_state(DOSING_MODE_CONTINUOUS);
279 break;
280
281 case EZO_PMP_COMMAND_STOP_DOSING: // Stop (page 62)
282 this->is_paused_flag_ = false;
283 if (this->is_paused_)
285 if (this->dosing_mode_ && this->dosing_mode_->state != DOSING_MODE_NONE)
286 this->dosing_mode_->publish_state(DOSING_MODE_NONE);
287 break;
288
289 case EZO_PMP_COMMAND_EXEC_ARBITRARY_COMMAND_ADDRESS:
290 ESP_LOGI(TAG, "Arbitrary Command Response: %s", (char *) response_buffer);
291 break;
292
293 case EZO_PMP_COMMAND_CLEAR_CALIBRATION: // Clear Calibration (page 65)
294 case EZO_PMP_COMMAND_PAUSE_DOSING: // Pause (page 61)
295 case EZO_PMP_COMMAND_SET_CALIBRATION_VOLUME: // Set Calibration Volume (page 65)
296 case EZO_PMP_COMMAND_CLEAR_TOTAL_VOLUME_DOSED: // Clear Total Volume Dosed (page 64)
297 case EZO_PMP_COMMAND_FIND: // Find (page 52)
298 // Nothing to do here
299 break;
300
301 case EZO_PMP_COMMAND_TYPE_READ:
302 case EZO_PMP_COMMAND_NONE:
303 default:
304 ESP_LOGE(TAG, "Unsupported command received: %d", this->current_command_);
305 return;
306 }
307
309}
310
312 int wait_time_for_command = 400; // milliseconds
313 uint8_t command_buffer[21];
314 int command_buffer_length = 0;
315
316 this->pop_next_command_(); // this->next_command will be updated.
317
318 switch (this->next_command_) {
319 // Read Commands
320 case EZO_PMP_COMMAND_READ_DOSING: // Page 54
321 command_buffer_length = sprintf((char *) command_buffer, "D,?");
322 break;
323
324 case EZO_PMP_COMMAND_READ_SINGLE_REPORT: // Single Report (page 53)
325 command_buffer_length = sprintf((char *) command_buffer, "R");
326 break;
327
328 case EZO_PMP_COMMAND_READ_MAX_FLOW_RATE:
329 command_buffer_length = sprintf((char *) command_buffer, "DC,?");
330 break;
331
332 case EZO_PMP_COMMAND_READ_PAUSE_STATUS:
333 command_buffer_length = sprintf((char *) command_buffer, "P,?");
334 break;
335
336 case EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED:
337 command_buffer_length = sprintf((char *) command_buffer, "TV,?");
338 break;
339
340 case EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED:
341 command_buffer_length = sprintf((char *) command_buffer, "ATV,?");
342 break;
343
344 case EZO_PMP_COMMAND_READ_CALIBRATION_STATUS:
345 command_buffer_length = sprintf((char *) command_buffer, "Cal,?");
346 break;
347
348 case EZO_PMP_COMMAND_READ_PUMP_VOLTAGE:
349 command_buffer_length = sprintf((char *) command_buffer, "PV,?");
350 break;
351
352 // Non-Read Commands
353
354 case EZO_PMP_COMMAND_FIND: // Find (page 52)
355 command_buffer_length = sprintf((char *) command_buffer, "Find");
356 wait_time_for_command = 60000; // This command will block all updates for a minute
357 break;
358
359 case EZO_PMP_COMMAND_DOSE_CONTINUOUSLY: // Continuous Dispensing (page 54)
360 command_buffer_length = sprintf((char *) command_buffer, "D,*");
361 break;
362
363 case EZO_PMP_COMMAND_CLEAR_TOTAL_VOLUME_DOSED: // Clear Total Volume Dosed (page 64)
364 command_buffer_length = sprintf((char *) command_buffer, "Clear");
365 break;
366
367 case EZO_PMP_COMMAND_CLEAR_CALIBRATION: // Clear Calibration (page 65)
368 command_buffer_length = sprintf((char *) command_buffer, "Cal,clear");
369 break;
370
371 case EZO_PMP_COMMAND_PAUSE_DOSING: // Pause (page 61)
372 command_buffer_length = sprintf((char *) command_buffer, "P");
373 break;
374
375 case EZO_PMP_COMMAND_STOP_DOSING: // Stop (page 62)
376 command_buffer_length = sprintf((char *) command_buffer, "X");
377 break;
378
379 // Non-Read commands with parameters
380
381 case EZO_PMP_COMMAND_DOSE_VOLUME: // Volume Dispensing (page 55)
382 command_buffer_length = sprintf((char *) command_buffer, "D,%0.1f", this->next_command_volume_);
383 break;
384
385 case EZO_PMP_COMMAND_DOSE_VOLUME_OVER_TIME: // Dose over time (page 56)
386 command_buffer_length =
387 sprintf((char *) command_buffer, "D,%0.1f,%i", this->next_command_volume_, this->next_command_duration_);
388 break;
389
390 case EZO_PMP_COMMAND_DOSE_WITH_CONSTANT_FLOW_RATE: // Constant Flow Rate (page 57)
391 command_buffer_length =
392 sprintf((char *) command_buffer, "DC,%0.1f,%i", this->next_command_volume_, this->next_command_duration_);
393 break;
394
395 case EZO_PMP_COMMAND_SET_CALIBRATION_VOLUME: // Set Calibration Volume (page 65)
396 command_buffer_length = sprintf((char *) command_buffer, "Cal,%0.2f", this->next_command_volume_);
397 break;
398
399 case EZO_PMP_COMMAND_CHANGE_I2C_ADDRESS: // Change I2C Address (page 73)
400 command_buffer_length = sprintf((char *) command_buffer, "I2C,%i", this->next_command_duration_);
401 break;
402
403 case EZO_PMP_COMMAND_EXEC_ARBITRARY_COMMAND_ADDRESS: // Run an arbitrary command
404 command_buffer_length = sprintf((char *) command_buffer, this->arbitrary_command_, this->next_command_duration_);
405 ESP_LOGI(TAG, "Sending arbitrary command: %s", (char *) command_buffer);
406 break;
407
408 case EZO_PMP_COMMAND_TYPE_READ:
409 case EZO_PMP_COMMAND_NONE:
410 default:
411 ESP_LOGE(TAG, "Unsupported command received: %d", this->next_command_);
412 return;
413 }
414
415 // Send command
416 ESP_LOGV(TAG, "Sending command to device: %s", (char *) command_buffer);
417 this->write(command_buffer, command_buffer_length);
418
419 this->current_command_ = this->next_command_;
420 this->next_command_ = EZO_PMP_COMMAND_NONE;
421 this->is_waiting_ = true;
422 this->start_time_ = millis();
423 this->wait_time_ = wait_time_for_command;
424}
425
427 if (this->next_command_queue_length_ <= 0) {
428 ESP_LOGE(TAG, "Tried to dequeue command from empty queue");
429 this->next_command_ = EZO_PMP_COMMAND_NONE;
430 this->next_command_volume_ = 0;
431 this->next_command_duration_ = 0;
432 return;
433 }
434
435 // Read from Head
439
440 // Move positions
442 if (next_command_queue_head_ >= 10) {
444 }
445
447}
448
450 if (this->next_command_queue_length_ <= 0) {
451 return EZO_PMP_COMMAND_NONE;
452 }
453
455}
456
457void EzoPMP::queue_command_(uint16_t command, double volume, int duration, bool should_schedule) {
458 if (!should_schedule) {
459 return;
460 }
461
462 if (this->next_command_queue_length_ >= 10) {
463 ESP_LOGE(TAG, "Tried to queue command '%d' but queue is full", command);
464 return;
465 }
466
467 this->next_command_queue_[this->next_command_queue_last_] = command;
470
471 ESP_LOGV(TAG, "Queue command '%d' in position '%d'", command, next_command_queue_last_);
472
473 // Move positions
475 if (next_command_queue_last_ >= 10) {
477 }
478
480}
481
482// Actions
483
484void EzoPMP::find() { this->queue_command_(EZO_PMP_COMMAND_FIND, 0, 0, true); }
485
487 this->queue_command_(EZO_PMP_COMMAND_DOSE_CONTINUOUSLY, 0, 0, true);
488 this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
489 this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
490}
491
492void EzoPMP::dose_volume(double volume) {
493 this->queue_command_(EZO_PMP_COMMAND_DOSE_VOLUME, volume, 0, true);
494 this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
495 this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
496}
497
498void EzoPMP::dose_volume_over_time(double volume, int duration) {
499 this->queue_command_(EZO_PMP_COMMAND_DOSE_VOLUME_OVER_TIME, volume, duration, true);
500 this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
501 this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
502}
503
505 this->queue_command_(EZO_PMP_COMMAND_DOSE_WITH_CONSTANT_FLOW_RATE, volume, duration, true);
506 this->queue_command_(EZO_PMP_COMMAND_READ_DOSING, 0, 0, true);
507 this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, (bool) this->current_volume_dosed_);
508}
509
511 this->queue_command_(EZO_PMP_COMMAND_SET_CALIBRATION_VOLUME, volume, 0, true);
512 this->queue_command_(EZO_PMP_COMMAND_READ_CALIBRATION_STATUS, 0, 0, true);
513 this->queue_command_(EZO_PMP_COMMAND_READ_MAX_FLOW_RATE, 0, 0, true);
514}
515
517 this->queue_command_(EZO_PMP_COMMAND_CLEAR_TOTAL_VOLUME_DOSED, 0, 0, true);
518 this->queue_command_(EZO_PMP_COMMAND_READ_SINGLE_REPORT, 0, 0, true);
519 this->queue_command_(EZO_PMP_COMMAND_READ_TOTAL_VOLUME_DOSED, 0, 0, true);
520 this->queue_command_(EZO_PMP_COMMAND_READ_ABSOLUTE_TOTAL_VOLUME_DOSED, 0, 0, true);
521}
522
524 this->queue_command_(EZO_PMP_COMMAND_CLEAR_CALIBRATION, 0, 0, true);
525 this->queue_command_(EZO_PMP_COMMAND_READ_CALIBRATION_STATUS, 0, 0, true);
526 this->queue_command_(EZO_PMP_COMMAND_READ_MAX_FLOW_RATE, 0, 0, true);
527}
528
530 this->queue_command_(EZO_PMP_COMMAND_PAUSE_DOSING, 0, 0, true);
531 this->queue_command_(EZO_PMP_COMMAND_READ_PAUSE_STATUS, 0, 0, true);
532}
533
534void EzoPMP::stop_dosing() { this->queue_command_(EZO_PMP_COMMAND_STOP_DOSING, 0, 0, true); }
535
537 this->queue_command_(EZO_PMP_COMMAND_CHANGE_I2C_ADDRESS, 0, address, true);
538}
539
540void EzoPMP::exec_arbitrary_command(const std::basic_string<char> &command) {
541 this->arbitrary_command_ = command.c_str();
542 this->queue_command_(EZO_PMP_COMMAND_EXEC_ARBITRARY_COMMAND_ADDRESS, 0, 0, true);
543}
544
545} // namespace ezo_pmp
546} // namespace esphome
uint8_t address
Definition bl0906.h:4
bool is_failed() const
void publish_state(bool new_state)
Publish a new state to the front-end.
sensor::Sensor * total_volume_dosed_
Definition ezo_pmp.h:99
void exec_arbitrary_command(const std::basic_string< char > &command)
Definition ezo_pmp.cpp:540
const char * arbitrary_command_
Definition ezo_pmp.h:88
void dose_volume(double volume)
Definition ezo_pmp.cpp:492
uint16_t current_command_
Definition ezo_pmp.h:84
binary_sensor::BinarySensor * is_paused_
Definition ezo_pmp.h:108
int next_command_duration_queue_[10]
Definition ezo_pmp.h:79
sensor::Sensor * max_flow_rate_
Definition ezo_pmp.h:102
uint16_t next_command_queue_[10]
Definition ezo_pmp.h:77
void dump_config() override
Definition ezo_pmp.cpp:41
double next_command_volume_queue_[10]
Definition ezo_pmp.h:78
void set_calibration_volume(double volume)
Definition ezo_pmp.cpp:510
void change_i2c_address(int address)
Definition ezo_pmp.cpp:536
void queue_command_(uint16_t command, double volume, int duration, bool should_schedule)
Definition ezo_pmp.cpp:457
void loop() override
Definition ezo_pmp.cpp:81
binary_sensor::BinarySensor * is_dosing_
Definition ezo_pmp.h:107
sensor::Sensor * last_volume_requested_
Definition ezo_pmp.h:103
void dose_volume_over_time(double volume, int duration)
Definition ezo_pmp.cpp:498
uint16_t peek_next_command_()
Definition ezo_pmp.cpp:449
sensor::Sensor * absolute_total_volume_dosed_
Definition ezo_pmp.h:100
text_sensor::TextSensor * dosing_mode_
Definition ezo_pmp.h:112
sensor::Sensor * pump_voltage_
Definition ezo_pmp.h:101
sensor::Sensor * current_volume_dosed_
Definition ezo_pmp.h:98
void dose_with_constant_flow_rate(double volume, int duration)
Definition ezo_pmp.cpp:504
void update() override
Definition ezo_pmp.cpp:49
text_sensor::TextSensor * calibration_status_
Definition ezo_pmp.h:113
ErrorCode write(const uint8_t *data, size_t len) const
writes an array of bytes to a device using an I2CBus
Definition i2c.h:184
optional< std::array< uint8_t, N > > read_bytes_raw()
Definition i2c.h:231
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:76
void publish_state(const std::string &state)
uint8_t duration
Definition msa3xx.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
optional< T > parse_number(const char *str)
Parse an unsigned decimal number from a null-terminated string.
Definition helpers.h:640
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:25