Merge pull request #15 from ElVit/heatpump_esphome_2025.11
Fix breaking changes caused by ESPHome 2025.11 (fixes #14)
This commit is contained in:
commit
4512fc7633
|
|
@ -18,17 +18,16 @@ namespace esphome
|
|||
auto traits = climate::ClimateTraits();
|
||||
|
||||
//traits.set_supports_action(true);
|
||||
traits.set_supports_current_temperature(true);
|
||||
traits.add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE);
|
||||
traits.set_supported_modes({climate::CLIMATE_MODE_OFF, climate::CLIMATE_MODE_HEAT});
|
||||
if (this->cool_mode_ &&
|
||||
(this->id_ == ClimateIds::CONF_CLIMATE_ZONE1 ||
|
||||
this->id_ == ClimateIds::CONF_CLIMATE_ZONE2))
|
||||
{
|
||||
traits.set_supports_two_point_target_temperature(true);
|
||||
this->supported_modes_.insert(climate::CLIMATE_MODE_COOL);
|
||||
this->supported_modes_.insert(climate::CLIMATE_MODE_AUTO);
|
||||
traits.add_feature_flags(climate::CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE);
|
||||
traits.add_supported_mode(climate::CLIMATE_MODE_COOL);
|
||||
traits.add_supported_mode(climate::CLIMATE_MODE_AUTO);
|
||||
}
|
||||
|
||||
traits.set_supported_modes(this->supported_modes_);
|
||||
traits.set_visual_min_temperature(this->min_temperature_);
|
||||
traits.set_visual_max_temperature(this->max_temperature_);
|
||||
traits.set_visual_temperature_step(this->temperature_step_);
|
||||
|
|
@ -132,11 +131,11 @@ namespace esphome
|
|||
default: return;
|
||||
};
|
||||
|
||||
if (!this->get_traits().get_supports_two_point_target_temperature() &&
|
||||
if (!this->get_traits().has_feature_flags(climate::CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE) &&
|
||||
this->mode == new_mode &&
|
||||
this->target_temperature == new_target_temp_heat &&
|
||||
this->current_temperature == new_current_temp) return;
|
||||
if (this->get_traits().get_supports_two_point_target_temperature() &&
|
||||
if (this->get_traits().has_feature_flags(climate::CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE) &&
|
||||
this->mode == new_mode &&
|
||||
this->target_temperature_high == new_target_temp_heat &&
|
||||
this->target_temperature_low == new_target_temp_cool &&
|
||||
|
|
@ -144,7 +143,7 @@ namespace esphome
|
|||
|
||||
if (new_mode != 255) this->mode = (climate::ClimateMode)new_mode;
|
||||
//this->action = climate::CLIMATE_ACTION_IDLE;
|
||||
if (this->get_traits().get_supports_two_point_target_temperature())
|
||||
if (this->get_traits().has_feature_flags(climate::CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE))
|
||||
{
|
||||
this->target_temperature_high = new_target_temp_heat;
|
||||
this->target_temperature_low = new_target_temp_cool;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "../panasonic_heatpump.h"
|
||||
#include "../decode.h"
|
||||
#include "../commands.h"
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace esphome
|
||||
|
|
@ -40,7 +41,6 @@ namespace esphome
|
|||
float min_temperature_ { -5.0 };
|
||||
float max_temperature_ { 5.0 };
|
||||
float temperature_step_ { 0.5 };
|
||||
std::set<climate::ClimateMode> supported_modes_ { climate::CLIMATE_MODE_OFF, climate::CLIMATE_MODE_HEAT };
|
||||
};
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
|
|
|
|||
|
|
@ -34,13 +34,7 @@ namespace esphome
|
|||
ESP_LOGI(TAG, "%s %s[%i]", msgDir.c_str(), msgType.c_str(), length);
|
||||
delay(10);
|
||||
|
||||
char buffer[5];
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (i > 0) logStr += separator;
|
||||
sprintf(buffer, "%02X", data[i]);
|
||||
logStr += buffer;
|
||||
}
|
||||
logStr += byte_array_to_hex_string(data, length, separator);
|
||||
|
||||
for (size_t i = 0; i < logStr.length(); i += UART_LOG_CHUNK_SIZE)
|
||||
{
|
||||
|
|
@ -48,5 +42,25 @@ namespace esphome
|
|||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
std::string PanasonicHelpers::byte_array_to_hex_string(const std::vector<uint8_t>& data, const char separator)
|
||||
{
|
||||
return PanasonicHelpers::byte_array_to_hex_string(&data[0], data.size(), separator);
|
||||
}
|
||||
|
||||
std::string PanasonicHelpers::byte_array_to_hex_string(const uint8_t* data, const size_t length, const char separator)
|
||||
{
|
||||
std::string hexStr = "";
|
||||
char buffer[5];
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (i > 0) hexStr += separator;
|
||||
sprintf(buffer, "%02X", data[i]);
|
||||
hexStr += buffer;
|
||||
}
|
||||
|
||||
return hexStr;
|
||||
}
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ namespace esphome
|
|||
public:
|
||||
static void log_uart_hex(UartLogDirection direction, const std::vector<uint8_t>& data, const char separator);
|
||||
static void log_uart_hex(UartLogDirection direction, const uint8_t* data, const size_t length, const char separator);
|
||||
static std::string byte_array_to_hex_string(const std::vector<uint8_t>& data, const char separator);
|
||||
static std::string byte_array_to_hex_string(const uint8_t* data, const size_t length, const char separator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -148,13 +148,21 @@ namespace esphome
|
|||
{
|
||||
this->payload_length_ = byte_;
|
||||
}
|
||||
// Discard message if format is wrong
|
||||
if ((this->response_message_.size() == 3 && byte_ != 0x01 && byte_ != 0x10) ||
|
||||
(this->response_message_.size() == 4 && byte_ != 0x10 && byte_ != 0x21))
|
||||
// 3. byte shall be 0x01 or 0x10
|
||||
if (this->response_message_.size() == 3 && byte_ != 0x01 && byte_ != 0x10)
|
||||
{
|
||||
this->response_receiving_ = false;
|
||||
ESP_LOGW(TAG, "Invalid response message: %d. byte is 0x%02X but expexted is 0x01, 0x10 or 0x21",
|
||||
response_message_.size(), byte_);
|
||||
ESP_LOGW(TAG, "Invalid response message: 0x%s. Expected last byte to be 0x01 or 0x10",
|
||||
PanasonicHelpers::byte_array_to_hex_string(this->response_message_, ','));
|
||||
delay(10); // NOLINT
|
||||
continue;
|
||||
}
|
||||
// 4. byte shall be 0x10 or 0x21
|
||||
if (this->response_message_.size() == 4 && byte_ != 0x10 && byte_ != 0x21)
|
||||
{
|
||||
this->response_receiving_ = false;
|
||||
ESP_LOGW(TAG, "Invalid response message: 0x%s. Expected last byte to be 0x10 or 0x21",
|
||||
PanasonicHelpers::byte_array_to_hex_string(this->response_message_, ','));
|
||||
delay(10); // NOLINT
|
||||
continue;
|
||||
}
|
||||
|
|
@ -225,13 +233,21 @@ namespace esphome
|
|||
{
|
||||
this->payload_length_ = byte_;
|
||||
}
|
||||
// Discard message if format is wrong
|
||||
if ((this->request_message_.size() == 3 && byte_ != 0x01 && byte_ != 0x10) ||
|
||||
(this->request_message_.size() == 4 && byte_ != 0x10 && byte_ != 0x21))
|
||||
// 3. byte shall be 0x01 or 0x10
|
||||
if (this->request_message_.size() == 3 && byte_ != 0x01 && byte_ != 0x10)
|
||||
{
|
||||
this->request_receiving_ = false;
|
||||
ESP_LOGW(TAG, "Invalid request message: %d. byte is 0x%02X but expexted is 0x01, 0x10 or 0x21",
|
||||
request_message_.size(), byte_);
|
||||
ESP_LOGW(TAG, "Invalid request message: 0x%s. Expected last byte to be 0x01 or 0x10",
|
||||
PanasonicHelpers::byte_array_to_hex_string(this->request_message_, ','));
|
||||
delay(10); // NOLINT
|
||||
continue;
|
||||
}
|
||||
// 4. byte shall be 0x10 or 0x21
|
||||
if (this->request_message_.size() == 4 && byte_ != 0x10 && byte_ != 0x21)
|
||||
{
|
||||
this->request_receiving_ = false;
|
||||
ESP_LOGW(TAG, "Invalid request message: 0x%s. Expected last byte to be 0x10 or 0x21",
|
||||
PanasonicHelpers::byte_array_to_hex_string(this->request_message_, ','));
|
||||
delay(10); // NOLINT
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,31 +63,31 @@ namespace esphome
|
|||
{
|
||||
case SelectIds::CONF_SET9:
|
||||
new_state = PanasonicDecode::getTextState(PanasonicDecode::OperationMode, PanasonicDecode::getOperationMode(data[6]));
|
||||
if (this->has_state() && this->state == new_state) return;
|
||||
if (this->has_state() && this->current_option() == new_state) return;
|
||||
break;
|
||||
case SelectIds::CONF_SET4:
|
||||
new_state = PanasonicDecode::getTextState(PanasonicDecode::PowerfulMode, PanasonicDecode::getBit6and7and8(data[7]));
|
||||
if (this->has_state() && this->state == new_state) return;
|
||||
if (this->has_state() && this->current_option() == new_state) return;
|
||||
break;
|
||||
case SelectIds::CONF_SET3:
|
||||
new_state = PanasonicDecode::getTextState(PanasonicDecode::QuietMode, PanasonicDecode::getBit3and4and5(data[7]));
|
||||
if (this->has_state() && this->state == new_state) return;
|
||||
if (this->has_state() && this->current_option() == new_state) return;
|
||||
break;
|
||||
case SelectIds::CONF_SET2:
|
||||
new_state = PanasonicDecode::getTextState(PanasonicDecode::HolidayState, PanasonicDecode::getBit3and4(data[5]));
|
||||
if (this->has_state() && this->state == new_state) return;
|
||||
if (this->has_state() && this->current_option() == new_state) return;
|
||||
break;
|
||||
case SelectIds::CONF_SET17:
|
||||
new_state = PanasonicDecode::getTextState(PanasonicDecode::ZoneState, PanasonicDecode::getBit1and2(data[6]));
|
||||
if (this->has_state() && this->state == new_state) return;
|
||||
if (this->has_state() && this->current_option() == new_state) return;
|
||||
break;
|
||||
case SelectIds::CONF_SET26:
|
||||
new_state = PanasonicDecode::getTextState(PanasonicDecode::ExtPadHeaterType, PanasonicDecode::getBit3and4(data[25]));
|
||||
if (this->has_state() && this->state == new_state) return;
|
||||
if (this->has_state() && this->current_option() == new_state) return;
|
||||
break;
|
||||
case SelectIds::CONF_SET35:
|
||||
new_state = PanasonicDecode::getTextState(PanasonicDecode::BivalentMode, PanasonicDecode::getBit5and6(data[26]));
|
||||
if (this->has_state() && this->state == new_state) return;
|
||||
if (this->has_state() && this->current_option() == new_state) return;
|
||||
break;
|
||||
default: return;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue