@@ -576,7 +576,7 @@ void JkBmsBle::decode_jk02_cell_info_(const std::vector<uint8_t> &data) {
576
576
577
577
if (frame_version == FRAME_VERSION_JK02_32S) {
578
578
uint16_t raw_emergency_time_countdown = jk_get_16bit (186 + offset);
579
- ESP_LOGI (TAG, " Emergency switch: %s" , (raw_emergency_time_countdown > 0 ) ? " on " : " off " );
579
+ ESP_LOGI (TAG, " Emergency switch: %s" , ONOFF (raw_emergency_time_countdown > 0 ));
580
580
this ->publish_state_ (this ->emergency_switch_ , raw_emergency_time_countdown > 0 );
581
581
this ->publish_state_ (this ->emergency_time_countdown_sensor_ , (float ) raw_emergency_time_countdown * 1 .0f );
582
582
@@ -891,15 +891,15 @@ void JkBmsBle::decode_jk02_settings_(const std::vector<uint8_t> &data) {
891
891
this ->publish_state_ (this ->cell_count_number_ , (float ) data[114 ]);
892
892
893
893
// 118 4 0x01 0x00 0x00 0x00 Charge switch
894
- ESP_LOGI (TAG, " Charge switch: %s" , ((bool ) data[118 ]) ? " on " : " off " );
894
+ ESP_LOGI (TAG, " Charge switch: %s" , ONOFF ((bool ) data[118 ]));
895
895
this ->publish_state_ (this ->charging_switch_ , (bool ) data[118 ]);
896
896
897
897
// 122 4 0x01 0x00 0x00 0x00 Discharge switch
898
- ESP_LOGI (TAG, " Discharge switch: %s" , ((bool ) data[122 ]) ? " on " : " off " );
898
+ ESP_LOGI (TAG, " Discharge switch: %s" , ONOFF ((bool ) data[122 ]));
899
899
this ->publish_state_ (this ->discharging_switch_ , (bool ) data[122 ]);
900
900
901
901
// 126 4 0x01 0x00 0x00 0x00 Balancer switch
902
- ESP_LOGI (TAG, " Balancer switch: %s" , ((bool ) data[126 ]) ? " on " : " off " );
902
+ ESP_LOGI (TAG, " Balancer switch: %s" , ONOFF ((bool ) data[126 ]));
903
903
this ->publish_state_ (this ->balancer_switch_ , (bool ) (data[126 ]));
904
904
905
905
// 130 4 0x88 0x13 0x00 0x00 Nominal battery capacity
@@ -969,7 +969,7 @@ void JkBmsBle::decode_jk02_settings_(const std::vector<uint8_t> &data) {
969
969
// bit6: SMART_SLEEP_ON_SWITCH_ENABLED 64
970
970
// bit7: DISABLE_PCL_MODULE_SWITCH_ENABLED 128
971
971
this ->publish_state_ (this ->heating_switch_ , check_bit_ (data[282 ], 1 ));
972
- ESP_LOGI (TAG, " Heating switch: %s" , (( bool ) check_bit_ (data[282 ], 1 )) ? " on " : " off " );
972
+ ESP_LOGI (TAG, " Heating switch: %s" , ONOFF ( check_bit_ (data[282 ], 1 )));
973
973
this ->publish_state_ (this ->disable_temperature_sensors_switch_ , check_bit_ (data[282 ], 2 ));
974
974
ESP_LOGI (TAG, " Port switch: %s" , check_bit_ (data[282 ], 8 ) ? " RS485" : " CAN" );
975
975
this ->publish_state_ (this ->display_always_on_switch_ , check_bit_ (data[282 ], 16 ));
@@ -988,12 +988,12 @@ void JkBmsBle::decode_jk02_settings_(const std::vector<uint8_t> &data) {
988
988
// bit7: ? 128
989
989
this ->publish_state_ (this ->timed_stored_data_switch_ , (bool ) this ->check_bit_ (data[283 ], 1 ));
990
990
this ->publish_state_ (this ->charging_float_mode_switch_ , (bool ) this ->check_bit_ (data[283 ], 2 ));
991
- ESP_LOGI (TAG, " Switch bit2: %s" , ( this -> check_bit_ (data[283 ], 4 )) ? " on " : " off " );
992
- ESP_LOGI (TAG, " Switch bit3: %s" , ( this -> check_bit_ (data[283 ], 8 )) ? " on " : " off " );
993
- ESP_LOGI (TAG, " Switch bit4: %s" , ( this -> check_bit_ (data[283 ], 16 )) ? " on " : " off " );
994
- ESP_LOGI (TAG, " Switch bit5: %s" , ( this -> check_bit_ (data[283 ], 32 )) ? " on " : " off " );
995
- ESP_LOGI (TAG, " Switch bit6: %s" , ( this -> check_bit_ (data[283 ], 64 )) ? " on " : " off " );
996
- ESP_LOGI (TAG, " Switch bit7: %s" , ( this -> check_bit_ (data[283 ], 128 )) ? " on " : " off " );
991
+ ESP_LOGI (TAG, " Switch bit2: %s" , ONOFF ( check_bit_ (data[283 ], 4 )));
992
+ ESP_LOGI (TAG, " Switch bit3: %s" , ONOFF ( check_bit_ (data[283 ], 8 )));
993
+ ESP_LOGI (TAG, " Switch bit4: %s" , ONOFF ( check_bit_ (data[283 ], 16 )));
994
+ ESP_LOGI (TAG, " Switch bit5: %s" , ONOFF ( check_bit_ (data[283 ], 32 )));
995
+ ESP_LOGI (TAG, " Switch bit6: %s" , ONOFF ( check_bit_ (data[283 ], 64 )));
996
+ ESP_LOGI (TAG, " Switch bit7: %s" , ONOFF ( check_bit_ (data[283 ], 128 )));
997
997
// 283 3 0x00 0x00 0x00
998
998
// 286 4 0x00 0x00 0x00 0x00
999
999
// 290 4 0x00 0x00 0x00 0x00
0 commit comments