ESPHome  2022.6.3
daly_bms.h
Go to the documentation of this file.
1 #pragma once
2 
8 
9 namespace esphome {
10 namespace daly_bms {
11 
13  public:
14  DalyBmsComponent() = default;
15 
16  // SENSORS
17  void set_voltage_sensor(sensor::Sensor *voltage_sensor) { voltage_sensor_ = voltage_sensor; }
18  void set_current_sensor(sensor::Sensor *current_sensor) { current_sensor_ = current_sensor; }
19  void set_battery_level_sensor(sensor::Sensor *battery_level_sensor) { battery_level_sensor_ = battery_level_sensor; }
20  void set_max_cell_voltage_sensor(sensor::Sensor *max_cell_voltage) { max_cell_voltage_ = max_cell_voltage; }
21  void set_max_cell_voltage_number_sensor(sensor::Sensor *max_cell_voltage_number) {
22  max_cell_voltage_number_ = max_cell_voltage_number;
23  }
24  void set_min_cell_voltage_sensor(sensor::Sensor *min_cell_voltage) { min_cell_voltage_ = min_cell_voltage; }
25  void set_min_cell_voltage_number_sensor(sensor::Sensor *min_cell_voltage_number) {
26  min_cell_voltage_number_ = min_cell_voltage_number;
27  }
28  void set_max_temperature_sensor(sensor::Sensor *max_temperature) { max_temperature_ = max_temperature; }
29  void set_max_temperature_probe_number_sensor(sensor::Sensor *max_temperature_probe_number) {
30  max_temperature_probe_number_ = max_temperature_probe_number;
31  }
32  void set_min_temperature_sensor(sensor::Sensor *min_temperature) { min_temperature_ = min_temperature; }
33  void set_min_temperature_probe_number_sensor(sensor::Sensor *min_temperature_probe_number) {
34  min_temperature_probe_number_ = min_temperature_probe_number;
35  }
36  void set_remaining_capacity_sensor(sensor::Sensor *remaining_capacity) { remaining_capacity_ = remaining_capacity; }
37  void set_cells_number_sensor(sensor::Sensor *cells_number) { cells_number_ = cells_number; }
38  void set_temperature_1_sensor(sensor::Sensor *temperature_1_sensor) { temperature_1_sensor_ = temperature_1_sensor; }
39  void set_temperature_2_sensor(sensor::Sensor *temperature_2_sensor) { temperature_2_sensor_ = temperature_2_sensor; }
40  void set_cell_1_voltage_sensor(sensor::Sensor *cell_1_voltage) { cell_1_voltage_ = cell_1_voltage; }
41  void set_cell_2_voltage_sensor(sensor::Sensor *cell_2_voltage) { cell_2_voltage_ = cell_2_voltage; }
42  void set_cell_3_voltage_sensor(sensor::Sensor *cell_3_voltage) { cell_3_voltage_ = cell_3_voltage; }
43  void set_cell_4_voltage_sensor(sensor::Sensor *cell_4_voltage) { cell_4_voltage_ = cell_4_voltage; }
44  void set_cell_5_voltage_sensor(sensor::Sensor *cell_5_voltage) { cell_5_voltage_ = cell_5_voltage; }
45  void set_cell_6_voltage_sensor(sensor::Sensor *cell_6_voltage) { cell_6_voltage_ = cell_6_voltage; }
46  void set_cell_7_voltage_sensor(sensor::Sensor *cell_7_voltage) { cell_7_voltage_ = cell_7_voltage; }
47  void set_cell_8_voltage_sensor(sensor::Sensor *cell_8_voltage) { cell_8_voltage_ = cell_8_voltage; }
48  void set_cell_9_voltage_sensor(sensor::Sensor *cell_9_voltage) { cell_9_voltage_ = cell_9_voltage; }
49  void set_cell_10_voltage_sensor(sensor::Sensor *cell_10_voltage) { cell_10_voltage_ = cell_10_voltage; }
50  void set_cell_11_voltage_sensor(sensor::Sensor *cell_11_voltage) { cell_11_voltage_ = cell_11_voltage; }
51  void set_cell_12_voltage_sensor(sensor::Sensor *cell_12_voltage) { cell_12_voltage_ = cell_12_voltage; }
52  void set_cell_13_voltage_sensor(sensor::Sensor *cell_13_voltage) { cell_13_voltage_ = cell_13_voltage; }
53  void set_cell_14_voltage_sensor(sensor::Sensor *cell_14_voltage) { cell_14_voltage_ = cell_14_voltage; }
54  void set_cell_15_voltage_sensor(sensor::Sensor *cell_15_voltage) { cell_15_voltage_ = cell_15_voltage; }
55  void set_cell_16_voltage_sensor(sensor::Sensor *cell_16_voltage) { cell_16_voltage_ = cell_16_voltage; }
56 
57  // TEXT_SENSORS
58  void set_status_text_sensor(text_sensor::TextSensor *status_text_sensor) { status_text_sensor_ = status_text_sensor; }
59  // BINARY_SENSORS
61  charging_mos_enabled_ = charging_mos_enabled;
62  }
64  discharging_mos_enabled_ = discharging_mos_enabled;
65  }
66 
67  void setup() override;
68  void dump_config() override;
69  void update() override;
70 
71  float get_setup_priority() const override;
72 
73  protected:
74  void request_data_(uint8_t data_id);
75  void decode_data_(std::vector<uint8_t> data);
76 
108 
110 
113 };
114 
115 } // namespace daly_bms
116 } // namespace esphome
sensor::Sensor * cell_15_voltage_
Definition: daly_bms.h:106
void set_cell_3_voltage_sensor(sensor::Sensor *cell_3_voltage)
Definition: daly_bms.h:42
sensor::Sensor * min_temperature_probe_number_
Definition: daly_bms.h:87
void set_cell_16_voltage_sensor(sensor::Sensor *cell_16_voltage)
Definition: daly_bms.h:55
void set_max_cell_voltage_sensor(sensor::Sensor *max_cell_voltage)
Definition: daly_bms.h:20
sensor::Sensor * max_cell_voltage_number_
Definition: daly_bms.h:81
sensor::Sensor * remaining_capacity_
Definition: daly_bms.h:88
sensor::Sensor * temperature_2_sensor_
Definition: daly_bms.h:91
void set_cell_10_voltage_sensor(sensor::Sensor *cell_10_voltage)
Definition: daly_bms.h:49
sensor::Sensor * temperature_1_sensor_
Definition: daly_bms.h:90
sensor::Sensor * current_sensor_
Definition: daly_bms.h:78
void set_charging_mos_enabled_binary_sensor(binary_sensor::BinarySensor *charging_mos_enabled)
Definition: daly_bms.h:60
void set_cell_12_voltage_sensor(sensor::Sensor *cell_12_voltage)
Definition: daly_bms.h:51
sensor::Sensor * min_cell_voltage_
Definition: daly_bms.h:82
void set_cell_4_voltage_sensor(sensor::Sensor *cell_4_voltage)
Definition: daly_bms.h:43
This class simplifies creating components that periodically check a state.
Definition: component.h:266
binary_sensor::BinarySensor * discharging_mos_enabled_
Definition: daly_bms.h:112
sensor::Sensor * cell_5_voltage_
Definition: daly_bms.h:96
sensor::Sensor * min_cell_voltage_number_
Definition: daly_bms.h:83
void set_temperature_1_sensor(sensor::Sensor *temperature_1_sensor)
Definition: daly_bms.h:38
void set_cell_1_voltage_sensor(sensor::Sensor *cell_1_voltage)
Definition: daly_bms.h:40
void set_voltage_sensor(sensor::Sensor *voltage_sensor)
Definition: daly_bms.h:17
sensor::Sensor * cell_6_voltage_
Definition: daly_bms.h:97
sensor::Sensor * cell_8_voltage_
Definition: daly_bms.h:99
sensor::Sensor * cell_11_voltage_
Definition: daly_bms.h:102
void set_cell_9_voltage_sensor(sensor::Sensor *cell_9_voltage)
Definition: daly_bms.h:48
void set_discharging_mos_enabled_binary_sensor(binary_sensor::BinarySensor *discharging_mos_enabled)
Definition: daly_bms.h:63
void set_max_temperature_probe_number_sensor(sensor::Sensor *max_temperature_probe_number)
Definition: daly_bms.h:29
void set_max_temperature_sensor(sensor::Sensor *max_temperature)
Definition: daly_bms.h:28
void request_data_(uint8_t data_id)
Definition: daly_bms.cpp:49
void set_cell_6_voltage_sensor(sensor::Sensor *cell_6_voltage)
Definition: daly_bms.h:45
sensor::Sensor * cell_10_voltage_
Definition: daly_bms.h:101
void set_cell_5_voltage_sensor(sensor::Sensor *cell_5_voltage)
Definition: daly_bms.h:44
sensor::Sensor * cell_16_voltage_
Definition: daly_bms.h:107
text_sensor::TextSensor * status_text_sensor_
Definition: daly_bms.h:109
void set_cell_7_voltage_sensor(sensor::Sensor *cell_7_voltage)
Definition: daly_bms.h:46
void decode_data_(std::vector< uint8_t > data)
Definition: daly_bms.cpp:71
sensor::Sensor * voltage_sensor_
Definition: daly_bms.h:77
sensor::Sensor * cell_4_voltage_
Definition: daly_bms.h:95
sensor::Sensor * min_temperature_
Definition: daly_bms.h:86
void set_min_temperature_probe_number_sensor(sensor::Sensor *min_temperature_probe_number)
Definition: daly_bms.h:33
sensor::Sensor * max_temperature_probe_number_
Definition: daly_bms.h:85
sensor::Sensor * cell_3_voltage_
Definition: daly_bms.h:94
sensor::Sensor * max_cell_voltage_
Definition: daly_bms.h:80
void set_min_cell_voltage_number_sensor(sensor::Sensor *min_cell_voltage_number)
Definition: daly_bms.h:25
sensor::Sensor * battery_level_sensor_
Definition: daly_bms.h:79
binary_sensor::BinarySensor * charging_mos_enabled_
Definition: daly_bms.h:111
void set_cell_8_voltage_sensor(sensor::Sensor *cell_8_voltage)
Definition: daly_bms.h:47
void set_min_temperature_sensor(sensor::Sensor *min_temperature)
Definition: daly_bms.h:32
sensor::Sensor * cell_9_voltage_
Definition: daly_bms.h:100
void set_cell_2_voltage_sensor(sensor::Sensor *cell_2_voltage)
Definition: daly_bms.h:41
sensor::Sensor * cell_2_voltage_
Definition: daly_bms.h:93
sensor::Sensor * cell_13_voltage_
Definition: daly_bms.h:104
void set_max_cell_voltage_number_sensor(sensor::Sensor *max_cell_voltage_number)
Definition: daly_bms.h:21
sensor::Sensor * cell_14_voltage_
Definition: daly_bms.h:105
void set_cells_number_sensor(sensor::Sensor *cells_number)
Definition: daly_bms.h:37
void set_cell_11_voltage_sensor(sensor::Sensor *cell_11_voltage)
Definition: daly_bms.h:50
sensor::Sensor * cells_number_
Definition: daly_bms.h:89
float get_setup_priority() const override
Definition: daly_bms.cpp:47
Definition: a4988.cpp:4
void set_current_sensor(sensor::Sensor *current_sensor)
Definition: daly_bms.h:18
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:26
void set_temperature_2_sensor(sensor::Sensor *temperature_2_sensor)
Definition: daly_bms.h:39
sensor::Sensor * cell_12_voltage_
Definition: daly_bms.h:103
Base-class for all sensors.
Definition: sensor.h:47
void set_cell_14_voltage_sensor(sensor::Sensor *cell_14_voltage)
Definition: daly_bms.h:53
void set_status_text_sensor(text_sensor::TextSensor *status_text_sensor)
Definition: daly_bms.h:58
void set_remaining_capacity_sensor(sensor::Sensor *remaining_capacity)
Definition: daly_bms.h:36
void set_min_cell_voltage_sensor(sensor::Sensor *min_cell_voltage)
Definition: daly_bms.h:24
sensor::Sensor * max_temperature_
Definition: daly_bms.h:84
void set_cell_15_voltage_sensor(sensor::Sensor *cell_15_voltage)
Definition: daly_bms.h:54
sensor::Sensor * cell_7_voltage_
Definition: daly_bms.h:98
sensor::Sensor * cell_1_voltage_
Definition: daly_bms.h:92
void set_battery_level_sensor(sensor::Sensor *battery_level_sensor)
Definition: daly_bms.h:19
void set_cell_13_voltage_sensor(sensor::Sensor *cell_13_voltage)
Definition: daly_bms.h:52