134 auto it = data.begin();
136 while ((it = std::find(it, data.end(), 0xA5)) != data.end()) {
137 if (data.end() - it >= DALY_FRAME_SIZE && it[1] == 0x01) {
140 for (
int i = 0; i < 12; i++) {
148 case DALY_REQUEST_BATTERY_LEVEL:
149 if (this->voltage_sensor_) {
150 this->voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 10);
152 if (this->current_sensor_) {
153 this->current_sensor_->publish_state(((
float) (
encode_uint16(it[8], it[9]) - DALY_CURRENT_OFFSET) / 10));
155 if (this->battery_level_sensor_) {
156 this->battery_level_sensor_->publish_state((
float)
encode_uint16(it[10], it[11]) / 10);
160 case DALY_REQUEST_MIN_MAX_VOLTAGE:
161 if (this->max_cell_voltage_sensor_) {
162 this->max_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 1000);
164 if (this->max_cell_voltage_number_sensor_) {
165 this->max_cell_voltage_number_sensor_->publish_state(it[6]);
167 if (this->min_cell_voltage_sensor_) {
168 this->min_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
170 if (this->min_cell_voltage_number_sensor_) {
171 this->min_cell_voltage_number_sensor_->publish_state(it[9]);
175 case DALY_REQUEST_MIN_MAX_TEMPERATURE:
176 if (this->max_temperature_sensor_) {
177 this->max_temperature_sensor_->publish_state(it[4] - DALY_TEMPERATURE_OFFSET);
179 if (this->max_temperature_probe_number_sensor_) {
180 this->max_temperature_probe_number_sensor_->publish_state(it[5]);
182 if (this->min_temperature_sensor_) {
183 this->min_temperature_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
185 if (this->min_temperature_probe_number_sensor_) {
186 this->min_temperature_probe_number_sensor_->publish_state(it[7]);
190 case DALY_REQUEST_MOS:
191#ifdef USE_TEXT_SENSOR
192 if (this->status_text_sensor_ !=
nullptr) {
195 this->status_text_sensor_->publish_state(
"Stationary");
198 this->status_text_sensor_->publish_state(
"Charging");
201 this->status_text_sensor_->publish_state(
"Discharging");
208#ifdef USE_BINARY_SENSOR
209 if (this->charging_mos_enabled_binary_sensor_) {
210 this->charging_mos_enabled_binary_sensor_->publish_state(it[5]);
212 if (this->discharging_mos_enabled_binary_sensor_) {
213 this->discharging_mos_enabled_binary_sensor_->publish_state(it[6]);
217 if (this->remaining_capacity_sensor_) {
218 this->remaining_capacity_sensor_->publish_state((
float)
encode_uint32(it[8], it[9], it[10], it[11]) /
225 case DALY_REQUEST_STATUS:
226 if (this->cells_number_sensor_) {
227 this->cells_number_sensor_->publish_state(it[4]);
231 case DALY_REQUEST_TEMPERATURE:
233 if (this->temperature_1_sensor_) {
234 this->temperature_1_sensor_->publish_state(it[5] - DALY_TEMPERATURE_OFFSET);
236 if (this->temperature_2_sensor_) {
237 this->temperature_2_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
242 case DALY_REQUEST_CELL_VOLTAGE:
245 if (this->cell_1_voltage_sensor_) {
246 this->cell_1_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
248 if (this->cell_2_voltage_sensor_) {
249 this->cell_2_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
251 if (this->cell_3_voltage_sensor_) {
252 this->cell_3_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
256 if (this->cell_4_voltage_sensor_) {
257 this->cell_4_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
259 if (this->cell_5_voltage_sensor_) {
260 this->cell_5_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
262 if (this->cell_6_voltage_sensor_) {
263 this->cell_6_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
267 if (this->cell_7_voltage_sensor_) {
268 this->cell_7_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
270 if (this->cell_8_voltage_sensor_) {
271 this->cell_8_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
273 if (this->cell_9_voltage_sensor_) {
274 this->cell_9_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
278 if (this->cell_10_voltage_sensor_) {
279 this->cell_10_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
281 if (this->cell_11_voltage_sensor_) {
282 this->cell_11_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
284 if (this->cell_12_voltage_sensor_) {
285 this->cell_12_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
289 if (this->cell_13_voltage_sensor_) {
290 this->cell_13_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
292 if (this->cell_14_voltage_sensor_) {
293 this->cell_14_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
295 if (this->cell_15_voltage_sensor_) {
296 this->cell_15_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
300 if (this->cell_16_voltage_sensor_) {
301 this->cell_16_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
303 if (this->cell_17_voltage_sensor_) {
304 this->cell_17_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
306 if (this->cell_18_voltage_sensor_) {
307 this->cell_18_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
317 ESP_LOGW(TAG,
"Checksum-Error on Packet %x", it[4]);
319 std::advance(it, DALY_FRAME_SIZE);