129 auto it = data.begin();
131 while ((it = std::find(it, data.end(), 0xA5)) != data.end()) {
132 if (data.end() - it >= DALY_FRAME_SIZE && it[1] == 0x01) {
138 case DALY_REQUEST_BATTERY_LEVEL:
139 if (this->voltage_sensor_) {
140 this->voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 10);
142 if (this->current_sensor_) {
143 this->current_sensor_->publish_state(((
float) (
encode_uint16(it[8], it[9]) - DALY_CURRENT_OFFSET) / 10));
145 if (this->battery_level_sensor_) {
146 this->battery_level_sensor_->publish_state((
float)
encode_uint16(it[10], it[11]) / 10);
150 case DALY_REQUEST_MIN_MAX_VOLTAGE:
151 if (this->max_cell_voltage_sensor_) {
152 this->max_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[4], it[5]) / 1000);
154 if (this->max_cell_voltage_number_sensor_) {
155 this->max_cell_voltage_number_sensor_->publish_state(it[6]);
157 if (this->min_cell_voltage_sensor_) {
158 this->min_cell_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
160 if (this->min_cell_voltage_number_sensor_) {
161 this->min_cell_voltage_number_sensor_->publish_state(it[9]);
165 case DALY_REQUEST_MIN_MAX_TEMPERATURE:
166 if (this->max_temperature_sensor_) {
167 this->max_temperature_sensor_->publish_state(it[4] - DALY_TEMPERATURE_OFFSET);
169 if (this->max_temperature_probe_number_sensor_) {
170 this->max_temperature_probe_number_sensor_->publish_state(it[5]);
172 if (this->min_temperature_sensor_) {
173 this->min_temperature_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
175 if (this->min_temperature_probe_number_sensor_) {
176 this->min_temperature_probe_number_sensor_->publish_state(it[7]);
180 case DALY_REQUEST_MOS:
181#ifdef USE_TEXT_SENSOR
182 if (this->status_text_sensor_ !=
nullptr) {
185 this->status_text_sensor_->publish_state(
"Stationary");
188 this->status_text_sensor_->publish_state(
"Charging");
191 this->status_text_sensor_->publish_state(
"Discharging");
198#ifdef USE_BINARY_SENSOR
199 if (this->charging_mos_enabled_binary_sensor_) {
200 this->charging_mos_enabled_binary_sensor_->publish_state(it[5]);
202 if (this->discharging_mos_enabled_binary_sensor_) {
203 this->discharging_mos_enabled_binary_sensor_->publish_state(it[6]);
207 if (this->remaining_capacity_sensor_) {
208 this->remaining_capacity_sensor_->publish_state((
float)
encode_uint32(it[8], it[9], it[10], it[11]) /
215 case DALY_REQUEST_STATUS:
216 if (this->cells_number_sensor_) {
217 this->cells_number_sensor_->publish_state(it[4]);
221 case DALY_REQUEST_TEMPERATURE:
223 if (this->temperature_1_sensor_) {
224 this->temperature_1_sensor_->publish_state(it[5] - DALY_TEMPERATURE_OFFSET);
226 if (this->temperature_2_sensor_) {
227 this->temperature_2_sensor_->publish_state(it[6] - DALY_TEMPERATURE_OFFSET);
232 case DALY_REQUEST_CELL_VOLTAGE:
235 if (this->cell_1_voltage_sensor_) {
236 this->cell_1_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
238 if (this->cell_2_voltage_sensor_) {
239 this->cell_2_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
241 if (this->cell_3_voltage_sensor_) {
242 this->cell_3_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
246 if (this->cell_4_voltage_sensor_) {
247 this->cell_4_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
249 if (this->cell_5_voltage_sensor_) {
250 this->cell_5_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
252 if (this->cell_6_voltage_sensor_) {
253 this->cell_6_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
257 if (this->cell_7_voltage_sensor_) {
258 this->cell_7_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
260 if (this->cell_8_voltage_sensor_) {
261 this->cell_8_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
263 if (this->cell_9_voltage_sensor_) {
264 this->cell_9_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
268 if (this->cell_10_voltage_sensor_) {
269 this->cell_10_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
271 if (this->cell_11_voltage_sensor_) {
272 this->cell_11_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
274 if (this->cell_12_voltage_sensor_) {
275 this->cell_12_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
279 if (this->cell_13_voltage_sensor_) {
280 this->cell_13_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
282 if (this->cell_14_voltage_sensor_) {
283 this->cell_14_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
285 if (this->cell_15_voltage_sensor_) {
286 this->cell_15_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
290 if (this->cell_16_voltage_sensor_) {
291 this->cell_16_voltage_sensor_->publish_state((
float)
encode_uint16(it[5], it[6]) / 1000);
293 if (this->cell_17_voltage_sensor_) {
294 this->cell_17_voltage_sensor_->publish_state((
float)
encode_uint16(it[7], it[8]) / 1000);
296 if (this->cell_18_voltage_sensor_) {
297 this->cell_18_voltage_sensor_->publish_state((
float)
encode_uint16(it[9], it[10]) / 1000);
307 ESP_LOGW(TAG,
"Checksum-Error on Packet %x", it[4]);
309 std::advance(it, DALY_FRAME_SIZE);