Merge remote-tracking branch 'origin/main' into heatpump/feature/uart-task-handling

This commit is contained in:
ElVit 2026-03-21 21:36:07 +01:00
commit b3f5f56ac5
7 changed files with 87 additions and 68 deletions

View File

@ -41,39 +41,42 @@ void PanasonicHeatpumpClimate::control(const climate::ClimateCall& call) {
if (call.get_target_temperature().has_value()) { if (call.get_target_temperature().has_value()) {
float new_temp = *call.get_target_temperature(); float new_temp = *call.get_target_temperature();
int new_temp_int = static_cast<int>(round(new_temp));
switch (this->id_) { switch (this->id_) {
case ClimateIds::CONF_CLIMATE_TANK: case ClimateIds::CONF_CLIMATE_TANK:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 42); // set11 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 42); // set11
break; break;
case ClimateIds::CONF_CLIMATE_ZONE1: case ClimateIds::CONF_CLIMATE_ZONE1:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 38); // set5 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 38); // set5
break; break;
case ClimateIds::CONF_CLIMATE_ZONE2: case ClimateIds::CONF_CLIMATE_ZONE2:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 40); // set7 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 40); // set7
break; break;
}; };
} }
if (call.get_target_temperature_high().has_value()) { if (call.get_target_temperature_high().has_value()) {
float new_temp = *call.get_target_temperature_high(); float new_temp = *call.get_target_temperature_high();
int new_temp_int = static_cast<int>(round(new_temp));
switch (this->id_) { switch (this->id_) {
case ClimateIds::CONF_CLIMATE_ZONE1: case ClimateIds::CONF_CLIMATE_ZONE1:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 38); // set5 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 38); // set5
break; break;
case ClimateIds::CONF_CLIMATE_ZONE2: case ClimateIds::CONF_CLIMATE_ZONE2:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 40); // set7 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 40); // set7
break; break;
}; };
} }
if (call.get_target_temperature_low().has_value()) { if (call.get_target_temperature_low().has_value()) {
float new_temp = *call.get_target_temperature_low(); float new_temp = *call.get_target_temperature_low();
int new_temp_int = static_cast<int>(round(new_temp));
switch (this->id_) { switch (this->id_) {
case ClimateIds::CONF_CLIMATE_ZONE1: case ClimateIds::CONF_CLIMATE_ZONE1:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 39); // set6 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 39); // set6
break; break;
case ClimateIds::CONF_CLIMATE_ZONE2: case ClimateIds::CONF_CLIMATE_ZONE2:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 41); // set8 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 41); // set8
break; break;
}; };
} }

View File

@ -38,39 +38,39 @@ uint8_t PanasonicCommand::calcChecksum(std::vector<uint8_t>& data, int length) {
return checksum; return checksum;
} }
uint8_t PanasonicCommand::setMultiply2(size_t input) { uint8_t PanasonicCommand::setMultiply2(int input) {
return input * 0b10; return input * 2;
} }
uint8_t PanasonicCommand::setMultiply4(size_t input) { uint8_t PanasonicCommand::setMultiply4(int input) {
return input * 0b100; return input * 4;
} }
uint8_t PanasonicCommand::setPlus1Multiply4(size_t input) { uint8_t PanasonicCommand::setPlus1Multiply4(int input) {
return (input + 1) * 0b100; return (input + 1) * 4;
} }
uint8_t PanasonicCommand::setPlus1Multiply8(size_t input) { uint8_t PanasonicCommand::setPlus1Multiply8(int input) {
return (input + 1) * 0b1000; return (input + 1) * 8;
} }
uint8_t PanasonicCommand::setPlus1Multiply16(size_t input) { uint8_t PanasonicCommand::setPlus1Multiply16(int input) {
return (input + 1) * 0b10000; return (input + 1) * 16;
} }
uint8_t PanasonicCommand::setPlus1Multiply64(size_t input) { uint8_t PanasonicCommand::setPlus1Multiply64(int input) {
return (input + 1) * 0b1000000; return (input + 1) * 64;
} }
uint8_t PanasonicCommand::setPlus1(size_t input) { uint8_t PanasonicCommand::setPlus1(int input) {
return input + 1; return input + 1;
} }
uint8_t PanasonicCommand::setPlus128(size_t input) { uint8_t PanasonicCommand::setPlus128(int input) {
return input + 0b10000000; return input + 128;
} }
uint8_t PanasonicCommand::setOperationMode(size_t input) { uint8_t PanasonicCommand::setOperationMode(int input) {
switch (input) { switch (input) {
case 0: case 0:
return 0b100001; // 0x21 = tank return 0b100001; // 0x21 = tank

View File

@ -22,15 +22,15 @@ class PanasonicCommand {
PanasonicCommand() = delete; PanasonicCommand() = delete;
static uint8_t calcChecksum(std::vector<uint8_t>& data, int length); static uint8_t calcChecksum(std::vector<uint8_t>& data, int length);
static uint8_t setMultiply2(size_t input); static uint8_t setMultiply2(int input);
static uint8_t setMultiply4(size_t input); static uint8_t setMultiply4(int input);
static uint8_t setPlus1Multiply4(size_t input); static uint8_t setPlus1Multiply4(int input);
static uint8_t setPlus1Multiply8(size_t input); static uint8_t setPlus1Multiply8(int input);
static uint8_t setPlus1Multiply16(size_t input); static uint8_t setPlus1Multiply16(int input);
static uint8_t setPlus1Multiply64(size_t input); static uint8_t setPlus1Multiply64(int input);
static uint8_t setPlus1(size_t input); static uint8_t setPlus1(int input);
static uint8_t setPlus128(size_t input); static uint8_t setPlus128(int input);
static uint8_t setOperationMode(size_t input); static uint8_t setOperationMode(int input);
static uint8_t temp2hex(float temp); static uint8_t temp2hex(float temp);
static uint8_t setByte6(uint8_t byte6, int val, int base, int bit); static uint8_t setByte6(uint8_t byte6, int val, int base, int bit);
static uint8_t setDemandControl(size_t input); static uint8_t setDemandControl(size_t input);

View File

@ -10,105 +10,106 @@ void PanasonicHeatpumpNumber::dump_config() {
} }
void PanasonicHeatpumpNumber::control(float value) { void PanasonicHeatpumpNumber::control(float value) {
int value_int = static_cast<int>(round(value));
switch (this->id_) { switch (this->id_) {
case NumberIds::CONF_SET5: case NumberIds::CONF_SET5:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 38); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 38);
break; break;
case NumberIds::CONF_SET6: case NumberIds::CONF_SET6:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 39); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 39);
break; break;
case NumberIds::CONF_SET7: case NumberIds::CONF_SET7:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 40); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 40);
break; break;
case NumberIds::CONF_SET8: case NumberIds::CONF_SET8:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 41); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 41);
break; break;
case NumberIds::CONF_SET11: case NumberIds::CONF_SET11:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 42); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 42);
break; break;
case NumberIds::CONF_SET15: case NumberIds::CONF_SET15:
this->parent_->set_command_byte(PanasonicCommand::setPlus1(value), 45); this->parent_->set_command_byte(PanasonicCommand::setPlus1(value_int), 45);
break; break;
case NumberIds::CONF_SET16_01: case NumberIds::CONF_SET16_01:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 75); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 75);
break; break;
case NumberIds::CONF_SET16_02: case NumberIds::CONF_SET16_02:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 76); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 76);
break; break;
case NumberIds::CONF_SET16_03: case NumberIds::CONF_SET16_03:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 77); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 77);
break; break;
case NumberIds::CONF_SET16_04: case NumberIds::CONF_SET16_04:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 78); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 78);
break; break;
case NumberIds::CONF_SET16_05: case NumberIds::CONF_SET16_05:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 79); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 79);
break; break;
case NumberIds::CONF_SET16_06: case NumberIds::CONF_SET16_06:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 80); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 80);
break; break;
case NumberIds::CONF_SET16_07: case NumberIds::CONF_SET16_07:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 81); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 81);
break; break;
case NumberIds::CONF_SET16_08: case NumberIds::CONF_SET16_08:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 82); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 82);
break; break;
case NumberIds::CONF_SET16_09: case NumberIds::CONF_SET16_09:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 86); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 86);
break; break;
case NumberIds::CONF_SET16_10: case NumberIds::CONF_SET16_10:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 87); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 87);
break; break;
case NumberIds::CONF_SET16_11: case NumberIds::CONF_SET16_11:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 88); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 88);
break; break;
case NumberIds::CONF_SET16_12: case NumberIds::CONF_SET16_12:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 89); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 89);
break; break;
case NumberIds::CONF_SET16_13: case NumberIds::CONF_SET16_13:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 90); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 90);
break; break;
case NumberIds::CONF_SET16_14: case NumberIds::CONF_SET16_14:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 91); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 91);
break; break;
case NumberIds::CONF_SET16_15: case NumberIds::CONF_SET16_15:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 92); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 92);
break; break;
case NumberIds::CONF_SET16_16: case NumberIds::CONF_SET16_16:
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 93); this->parent_->set_command_curve(PanasonicCommand::setPlus128(value_int), 93);
break; break;
case NumberIds::CONF_SET18: case NumberIds::CONF_SET18:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 84); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 84);
break; break;
case NumberIds::CONF_SET19: case NumberIds::CONF_SET19:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 94); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 94);
break; break;
case NumberIds::CONF_SET20: case NumberIds::CONF_SET20:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 99); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 99);
break; break;
case NumberIds::CONF_SET21: case NumberIds::CONF_SET21:
this->parent_->set_command_byte(PanasonicCommand::setPlus1(value), 104); this->parent_->set_command_byte(PanasonicCommand::setPlus1(value_int), 104);
break; break;
case NumberIds::CONF_SET22: case NumberIds::CONF_SET22:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 105); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 105);
break; break;
case NumberIds::CONF_SET23: case NumberIds::CONF_SET23:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 106); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 106);
break; break;
case NumberIds::CONF_SET27: case NumberIds::CONF_SET27:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 59); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 59);
break; break;
case NumberIds::CONF_SET29: case NumberIds::CONF_SET29:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 83); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 83);
break; break;
case NumberIds::CONF_SET36: case NumberIds::CONF_SET36:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 65); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 65);
break; break;
case NumberIds::CONF_SET37: case NumberIds::CONF_SET37:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 66); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 66);
break; break;
case NumberIds::CONF_SET38: case NumberIds::CONF_SET38:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 68); this->parent_->set_command_byte(PanasonicCommand::setPlus128(value_int), 68);
break; break;
default: default:
return; return;

View File

@ -6,7 +6,21 @@ namespace panasonic_heatpump {
static const char* const TAG = "panasonic_heatpump"; static const char* const TAG = "panasonic_heatpump";
void PanasonicHeatpumpComponent::dump_config() { void PanasonicHeatpumpComponent::dump_config() {
ESP_LOGW(TAG, "*** Panasonic Heatpump Component v%s ***", PANASONIC_HEATPUMP_VERSION); size_t version_len = strlen(PANASONIC_HEATPUMP_VERSION);
size_t line_width = 38 + version_len;
std::string border(line_width, '*');
if (strstr(PANASONIC_HEATPUMP_VERSION, "beta") != nullptr) {
ESP_LOGE(TAG, "%s", border.c_str());
ESP_LOGE(TAG, "*** Panasonic Heatpump Component v%s ***", PANASONIC_HEATPUMP_VERSION);
ESP_LOGE(TAG, "%s", border.c_str());
} else {
ESP_LOGW(TAG, "%s", border.c_str());
ESP_LOGW(TAG, "*** Panasonic Heatpump Component v%s ***", PANASONIC_HEATPUMP_VERSION);
ESP_LOGW(TAG, "%s", border.c_str());
}
delay(10); // NOLINT
} }
void PanasonicHeatpumpComponent::setup() { void PanasonicHeatpumpComponent::setup() {

View File

@ -10,7 +10,7 @@ void PanasonicHeatpumpSwitch::dump_config() {
} }
void PanasonicHeatpumpSwitch::write_state(bool state) { void PanasonicHeatpumpSwitch::write_state(bool state) {
size_t value = state ? 1 : 0; int value = state ? 1 : 0;
switch (this->id_) { switch (this->id_) {
case SwitchIds::CONF_SET1: case SwitchIds::CONF_SET1:

View File

@ -32,9 +32,10 @@ void PanasonicHeatpumpWaterHeater::control(const water_heater::WaterHeaterCall&
} }
float new_temp = call.get_target_temperature(); float new_temp = call.get_target_temperature();
int new_temp_int = static_cast<int>(round(new_temp));
switch (this->id_) { switch (this->id_) {
case WaterHeaterIds::CONF_HEATER_TANK: case WaterHeaterIds::CONF_HEATER_TANK:
this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp), 42); // set11 this->parent_->set_command_byte(PanasonicCommand::setPlus128(new_temp_int), 42); // set11
break; break;
}; };