Skip to content

Commit

Permalink
heating fully implemented, inplements Expose heating status and `he…
Browse files Browse the repository at this point in the history
…ating current` syssi#420
  • Loading branch information
RFDarter committed Jan 26, 2024
1 parent 2dad051 commit fd422da
Show file tree
Hide file tree
Showing 31 changed files with 243,338 additions and 1,745,215 deletions.
11 changes: 6 additions & 5 deletions components/jk_bms_ble/jk_bms_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ void JkBmsBle::dump_config() { // NOLINT(google-readability-function-size,reada
LOG_SENSOR("", "Charging Cycles", this->charging_cycles_sensor_);
LOG_SENSOR("", "Total Charging Cycle Capacity", this->total_charging_cycle_capacity_sensor_);
LOG_SENSOR("", "Total Runtime", this->total_runtime_sensor_);
LOG_SENSOR("", "Heating Current", this->heating_current_sensor_);
LOG_TEXT_SENSOR("", "Operation Status", this->operation_status_text_sensor_);
LOG_TEXT_SENSOR("", "Total Runtime Formatted", this->total_runtime_formatted_text_sensor_);
LOG_BINARY_SENSOR("", "Balancing", this->balancing_binary_sensor_);
LOG_BINARY_SENSOR("", "Charging", this->charging_binary_sensor_);
LOG_BINARY_SENSOR("", "Discharging", this->discharging_binary_sensor_);
LOG_BINARY_SENSOR("", "Heating", this->heating_binary_sensor_);
}

void JkBmsBle::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
Expand Down Expand Up @@ -556,11 +558,8 @@ void JkBmsBle::decode_jk02_cell_info_(const std::vector<uint8_t> &data) {
// 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
// 0x00

// 215 1 0x01 Heating status 0x00: off, 0x01: on
uint16_t raw_heating_status = (((215 + offset) != 0x00));
ESP_LOGD(TAG, " offset: %d", offset);
ESP_LOGD(TAG, " Heating status: %s", (raw_heating_status > 0) ? "on" : "off");
this->publish_state_(this->heating_binary_sensor_, (bool)raw_heating_status);
// 224 1 0x01 Heating status 0x00: off, 0x01: on
this->publish_state_(this->heating_binary_sensor_, (bool)data[224 + offset]);

// 236 2 0x01 0xFD Heating current 0.001 A
this->publish_state_(this->heating_current_sensor_, (float) ((int16_t) jk_get_16bit(236 + offset)) * 0.001f);
Expand Down Expand Up @@ -929,6 +928,7 @@ void JkBmsBle::decode_jk02_settings_(const std::vector<uint8_t> &data) {
// 274 4 0x00 0x00 0x00 0x00
// 278 4 0x00 0x00 0x00 0x00
// 282 1 0x00 New controls bitmask
this->publish_state_(this->heating_switch_, check_bit_(data[282], 1));
this->publish_state_(this->disable_temperature_sensors_switch_, check_bit_(data[282], 2));
this->publish_state_(this->display_always_on_switch_, check_bit_(data[282], 16));
ESP_LOGI(TAG, " Port switch: %s", check_bit_(data[282], 8) ? "RS485" : "CAN");
Expand Down Expand Up @@ -1178,6 +1178,7 @@ void JkBmsBle::publish_device_unavailable_() {
this->publish_state_(total_runtime_sensor_, NAN);
this->publish_state_(balancing_current_sensor_, NAN);
this->publish_state_(errors_bitmask_sensor_, NAN);
this->publish_state_(heating_current_sensor_, NAN);

for (auto &cell : this->cells_) {
this->publish_state_(cell.cell_voltage_sensor_, NAN);
Expand Down
2 changes: 1 addition & 1 deletion components/jk_bms_ble/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
CONF_DISCHARGING: [0x00, 0x1E, 0x1E],
CONF_BALANCER: [0x6C, 0x1F, 0x1F],
CONF_EMERGENCY: [0x00, 0x00, 0x6B],
CONF_HEATING: [0x00, 0x00, 0x27],
CONF_HEATING: [0x00, 0x27, 0x27],
CONF_DISABLE_TEMPERATURE_SENSORS: [0x00, 0x00, 0x28],
CONF_DISPLAY_ALWAYS_ON: [0x00, 0x00, 0x2B],
CONF_SMART_SLEEP: [0x00, 0x00, 0x2D],
Expand Down
Binary file removed docs/btsnoops/btsnoop_heating_off_2.log
Binary file not shown.
Loading

0 comments on commit fd422da

Please sign in to comment.