132 auto it = data.begin();
134 while ((it = std::find(it, data.end(), 0xA5)) != data.end()) {
135 if (data.end() - it >= DALY_FRAME_SIZE && it[1] == 0x01) {
138 for (
int i = 0; i < 12; i++) {
146 case DALY_REQUEST_BATTERY_LEVEL:
147 if (this->voltage_sensor_) {
148 this->voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 10);
150 if (this->current_sensor_) {
151 this->current_sensor_->publish_state(((
float) (
encode_uint16(it[8], it[9]) - DALY_CURRENT_OFFSET) / 10));
153 if (this->battery_level_sensor_) {
154 this->battery_level_sensor_->publish_state((
float)
encode_uint16(it[10], it[11]) / 10);
158 case DALY_REQUEST_MIN_MAX_VOLTAGE:
159 if (this->max_cell_voltage_sensor_) {
160 this->max_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 1000);
162 if (this->max_cell_voltage_number_sensor_) {
163 this->max_cell_voltage_number_sensor_->publish_state(it[6]);
165 if (this->min_cell_voltage_sensor_) {
166 this->min_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
168 if (this->min_cell_voltage_number_sensor_) {
169 this->min_cell_voltage_number_sensor_->publish_state(it[9]);
173 case DALY_REQUEST_MIN_MAX_TEMPERATURE:
174 if (this->max_temperature_sensor_) {
175 this->max_temperature_sensor_->publish_state(it[4] - DALY_TEMPERATURE_OFFSET);
177 if (this->max_temperature_probe_number_sensor_) {
178 this->max_temperature_probe_number_sensor_->publish_state(it[5]);
180 if (this->min_temperature_sensor_) {
181 this->min_temperature_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
183 if (this->min_temperature_probe_number_sensor_) {
184 this->min_temperature_probe_number_sensor_->publish_state(it[7]);
188 case DALY_REQUEST_MOS:
189#ifdef USE_TEXT_SENSOR
190 if (this->status_text_sensor_ !=
nullptr) {
193 this->status_text_sensor_->publish_state(
"Stationary");
196 this->status_text_sensor_->publish_state(
"Charging");
199 this->status_text_sensor_->publish_state(
"Discharging");
206#ifdef USE_BINARY_SENSOR
207 if (this->charging_mos_enabled_binary_sensor_) {
208 this->charging_mos_enabled_binary_sensor_->publish_state(it[5]);
210 if (this->discharging_mos_enabled_binary_sensor_) {
211 this->discharging_mos_enabled_binary_sensor_->publish_state(it[6]);
215 if (this->remaining_capacity_sensor_) {
216 this->remaining_capacity_sensor_->publish_state((
float)
encode_uint32(it[8], it[9], it[10], it[11]) /
223 case DALY_REQUEST_STATUS:
224 if (this->cells_number_sensor_) {
225 this->cells_number_sensor_->publish_state(it[4]);
229 case DALY_REQUEST_TEMPERATURE:
231 if (this->temperature_1_sensor_) {
232 this->temperature_1_sensor_->publish_state(it[5] - DALY_TEMPERATURE_OFFSET);
234 if (this->temperature_2_sensor_) {
235 this->temperature_2_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
240 case DALY_REQUEST_CELL_VOLTAGE:
243 if (this->cell_1_voltage_sensor_) {
244 this->cell_1_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
246 if (this->cell_2_voltage_sensor_) {
247 this->cell_2_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
249 if (this->cell_3_voltage_sensor_) {
250 this->cell_3_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
254 if (this->cell_4_voltage_sensor_) {
255 this->cell_4_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
257 if (this->cell_5_voltage_sensor_) {
258 this->cell_5_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
260 if (this->cell_6_voltage_sensor_) {
261 this->cell_6_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
265 if (this->cell_7_voltage_sensor_) {
266 this->cell_7_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
268 if (this->cell_8_voltage_sensor_) {
269 this->cell_8_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
271 if (this->cell_9_voltage_sensor_) {
272 this->cell_9_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
276 if (this->cell_10_voltage_sensor_) {
277 this->cell_10_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
279 if (this->cell_11_voltage_sensor_) {
280 this->cell_11_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
282 if (this->cell_12_voltage_sensor_) {
283 this->cell_12_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
287 if (this->cell_13_voltage_sensor_) {
288 this->cell_13_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
290 if (this->cell_14_voltage_sensor_) {
291 this->cell_14_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
293 if (this->cell_15_voltage_sensor_) {
294 this->cell_15_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
298 if (this->cell_16_voltage_sensor_) {
299 this->cell_16_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
301 if (this->cell_17_voltage_sensor_) {
302 this->cell_17_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
304 if (this->cell_18_voltage_sensor_) {
305 this->cell_18_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
315 ESP_LOGW(TAG,
"Checksum-Error on Packet %x", it[4]);
317 std::advance(it, DALY_FRAME_SIZE);