133 auto it = data.begin();
135 while ((it = std::find(it, data.end(), 0xA5)) != data.end()) {
136 if (data.end() - it >= DALY_FRAME_SIZE && it[1] == 0x01) {
139 for (
int i = 0; i < 12; i++) {
147 case DALY_REQUEST_BATTERY_LEVEL:
148 if (this->voltage_sensor_) {
149 this->voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 10);
151 if (this->current_sensor_) {
152 this->current_sensor_->publish_state(((
float) (
encode_uint16(it[8], it[9]) - DALY_CURRENT_OFFSET) / 10));
154 if (this->battery_level_sensor_) {
155 this->battery_level_sensor_->publish_state((
float)
encode_uint16(it[10], it[11]) / 10);
159 case DALY_REQUEST_MIN_MAX_VOLTAGE:
160 if (this->max_cell_voltage_sensor_) {
161 this->max_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 1000);
163 if (this->max_cell_voltage_number_sensor_) {
164 this->max_cell_voltage_number_sensor_->publish_state(it[6]);
166 if (this->min_cell_voltage_sensor_) {
167 this->min_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
169 if (this->min_cell_voltage_number_sensor_) {
170 this->min_cell_voltage_number_sensor_->publish_state(it[9]);
174 case DALY_REQUEST_MIN_MAX_TEMPERATURE:
175 if (this->max_temperature_sensor_) {
176 this->max_temperature_sensor_->publish_state(it[4] - DALY_TEMPERATURE_OFFSET);
178 if (this->max_temperature_probe_number_sensor_) {
179 this->max_temperature_probe_number_sensor_->publish_state(it[5]);
181 if (this->min_temperature_sensor_) {
182 this->min_temperature_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
184 if (this->min_temperature_probe_number_sensor_) {
185 this->min_temperature_probe_number_sensor_->publish_state(it[7]);
189 case DALY_REQUEST_MOS:
190#ifdef USE_TEXT_SENSOR
191 if (this->status_text_sensor_ !=
nullptr) {
194 this->status_text_sensor_->publish_state(
"Stationary");
197 this->status_text_sensor_->publish_state(
"Charging");
200 this->status_text_sensor_->publish_state(
"Discharging");
207#ifdef USE_BINARY_SENSOR
208 if (this->charging_mos_enabled_binary_sensor_) {
209 this->charging_mos_enabled_binary_sensor_->publish_state(it[5]);
211 if (this->discharging_mos_enabled_binary_sensor_) {
212 this->discharging_mos_enabled_binary_sensor_->publish_state(it[6]);
216 if (this->remaining_capacity_sensor_) {
217 this->remaining_capacity_sensor_->publish_state((
float)
encode_uint32(it[8], it[9], it[10], it[11]) /
224 case DALY_REQUEST_STATUS:
225 if (this->cells_number_sensor_) {
226 this->cells_number_sensor_->publish_state(it[4]);
230 case DALY_REQUEST_TEMPERATURE:
232 if (this->temperature_1_sensor_) {
233 this->temperature_1_sensor_->publish_state(it[5] - DALY_TEMPERATURE_OFFSET);
235 if (this->temperature_2_sensor_) {
236 this->temperature_2_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
241 case DALY_REQUEST_CELL_VOLTAGE:
244 if (this->cell_1_voltage_sensor_) {
245 this->cell_1_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
247 if (this->cell_2_voltage_sensor_) {
248 this->cell_2_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
250 if (this->cell_3_voltage_sensor_) {
251 this->cell_3_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
255 if (this->cell_4_voltage_sensor_) {
256 this->cell_4_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
258 if (this->cell_5_voltage_sensor_) {
259 this->cell_5_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
261 if (this->cell_6_voltage_sensor_) {
262 this->cell_6_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
266 if (this->cell_7_voltage_sensor_) {
267 this->cell_7_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
269 if (this->cell_8_voltage_sensor_) {
270 this->cell_8_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
272 if (this->cell_9_voltage_sensor_) {
273 this->cell_9_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
277 if (this->cell_10_voltage_sensor_) {
278 this->cell_10_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
280 if (this->cell_11_voltage_sensor_) {
281 this->cell_11_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
283 if (this->cell_12_voltage_sensor_) {
284 this->cell_12_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
288 if (this->cell_13_voltage_sensor_) {
289 this->cell_13_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
291 if (this->cell_14_voltage_sensor_) {
292 this->cell_14_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
294 if (this->cell_15_voltage_sensor_) {
295 this->cell_15_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
299 if (this->cell_16_voltage_sensor_) {
300 this->cell_16_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
302 if (this->cell_17_voltage_sensor_) {
303 this->cell_17_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
305 if (this->cell_18_voltage_sensor_) {
306 this->cell_18_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
316 ESP_LOGW(TAG,
"Checksum-Error on Packet %x", it[4]);
318 std::advance(it, DALY_FRAME_SIZE);