131 auto it = data.begin();
133 while ((it = std::find(it, data.end(), 0xA5)) != data.end()) {
134 if (data.end() - it >= DALY_FRAME_SIZE && it[1] == 0x01) {
137 for (
int i = 0; i < 12; i++) {
145 case DALY_REQUEST_BATTERY_LEVEL:
146 if (this->voltage_sensor_) {
147 this->voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 10);
149 if (this->current_sensor_) {
150 this->current_sensor_->publish_state(((
float) (
encode_uint16(it[8], it[9]) - DALY_CURRENT_OFFSET) / 10));
152 if (this->battery_level_sensor_) {
153 this->battery_level_sensor_->publish_state((
float)
encode_uint16(it[10], it[11]) / 10);
157 case DALY_REQUEST_MIN_MAX_VOLTAGE:
158 if (this->max_cell_voltage_sensor_) {
159 this->max_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 1000);
161 if (this->max_cell_voltage_number_sensor_) {
162 this->max_cell_voltage_number_sensor_->publish_state(it[6]);
164 if (this->min_cell_voltage_sensor_) {
165 this->min_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
167 if (this->min_cell_voltage_number_sensor_) {
168 this->min_cell_voltage_number_sensor_->publish_state(it[9]);
172 case DALY_REQUEST_MIN_MAX_TEMPERATURE:
173 if (this->max_temperature_sensor_) {
174 this->max_temperature_sensor_->publish_state(it[4] - DALY_TEMPERATURE_OFFSET);
176 if (this->max_temperature_probe_number_sensor_) {
177 this->max_temperature_probe_number_sensor_->publish_state(it[5]);
179 if (this->min_temperature_sensor_) {
180 this->min_temperature_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
182 if (this->min_temperature_probe_number_sensor_) {
183 this->min_temperature_probe_number_sensor_->publish_state(it[7]);
187 case DALY_REQUEST_MOS:
188#ifdef USE_TEXT_SENSOR
189 if (this->status_text_sensor_ !=
nullptr) {
192 this->status_text_sensor_->publish_state(
"Stationary");
195 this->status_text_sensor_->publish_state(
"Charging");
198 this->status_text_sensor_->publish_state(
"Discharging");
205#ifdef USE_BINARY_SENSOR
206 if (this->charging_mos_enabled_binary_sensor_) {
207 this->charging_mos_enabled_binary_sensor_->publish_state(it[5]);
209 if (this->discharging_mos_enabled_binary_sensor_) {
210 this->discharging_mos_enabled_binary_sensor_->publish_state(it[6]);
214 if (this->remaining_capacity_sensor_) {
215 this->remaining_capacity_sensor_->publish_state((
float)
encode_uint32(it[8], it[9], it[10], it[11]) /
222 case DALY_REQUEST_STATUS:
223 if (this->cells_number_sensor_) {
224 this->cells_number_sensor_->publish_state(it[4]);
228 case DALY_REQUEST_TEMPERATURE:
230 if (this->temperature_1_sensor_) {
231 this->temperature_1_sensor_->publish_state(it[5] - DALY_TEMPERATURE_OFFSET);
233 if (this->temperature_2_sensor_) {
234 this->temperature_2_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
239 case DALY_REQUEST_CELL_VOLTAGE:
242 if (this->cell_1_voltage_sensor_) {
243 this->cell_1_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
245 if (this->cell_2_voltage_sensor_) {
246 this->cell_2_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
248 if (this->cell_3_voltage_sensor_) {
249 this->cell_3_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
253 if (this->cell_4_voltage_sensor_) {
254 this->cell_4_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
256 if (this->cell_5_voltage_sensor_) {
257 this->cell_5_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
259 if (this->cell_6_voltage_sensor_) {
260 this->cell_6_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
264 if (this->cell_7_voltage_sensor_) {
265 this->cell_7_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
267 if (this->cell_8_voltage_sensor_) {
268 this->cell_8_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
270 if (this->cell_9_voltage_sensor_) {
271 this->cell_9_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
275 if (this->cell_10_voltage_sensor_) {
276 this->cell_10_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
278 if (this->cell_11_voltage_sensor_) {
279 this->cell_11_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
281 if (this->cell_12_voltage_sensor_) {
282 this->cell_12_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
286 if (this->cell_13_voltage_sensor_) {
287 this->cell_13_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
289 if (this->cell_14_voltage_sensor_) {
290 this->cell_14_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
292 if (this->cell_15_voltage_sensor_) {
293 this->cell_15_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
297 if (this->cell_16_voltage_sensor_) {
298 this->cell_16_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
300 if (this->cell_17_voltage_sensor_) {
301 this->cell_17_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
303 if (this->cell_18_voltage_sensor_) {
304 this->cell_18_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
314 ESP_LOGW(TAG,
"Checksum-Error on Packet %x", it[4]);
316 std::advance(it, DALY_FRAME_SIZE);