diff --git a/components/panasonic_heatpump/panasonic_heatpump.cpp b/components/panasonic_heatpump/panasonic_heatpump.cpp index 4784c34..47ec984 100644 --- a/components/panasonic_heatpump/panasonic_heatpump.cpp +++ b/components/panasonic_heatpump/panasonic_heatpump.cpp @@ -107,6 +107,7 @@ namespace esphome { // Probably not necessary but CZ-TAW1 sends this query on boot this->log_uart_hex(UART_LOG_TX, PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE, ','); + this->write_array(PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE); this->flush(); } @@ -202,10 +203,9 @@ namespace esphome logStr += buffer; } - size_t chunkSize = 150; - for (size_t i = 0; i < logStr.length(); i += chunkSize) + for (size_t i = 0; i < logStr.length(); i += UART_LOG_CHUNK_SIZE) { - ESP_LOGI(TAG, "%s %s", msgDir.c_str(), logStr.substr(i, chunkSize).c_str()); + ESP_LOGI(TAG, "%s %s", msgDir.c_str(), logStr.substr(i, UART_LOG_CHUNK_SIZE).c_str()); delay(10); } } diff --git a/components/panasonic_heatpump/panasonic_heatpump.h b/components/panasonic_heatpump/panasonic_heatpump.h index 3fa4f8c..ea3bf10 100644 --- a/components/panasonic_heatpump/panasonic_heatpump.h +++ b/components/panasonic_heatpump/panasonic_heatpump.h @@ -28,6 +28,8 @@ #include #include +#define UART_LOG_CHUNK_SIZE 153 + namespace esphome { @@ -264,13 +266,14 @@ namespace esphome // option functions void set_uart_client(uart::UARTComponent* uart) { this->uart_client_ = uart; } void set_log_uart_msg(bool enable) { this->log_uart_msg_ = enable; } + // uart message variables to use in lambda functions + std::vector response_message_; protected: // options variables uart::UARTComponent* uart_client_ { nullptr }; bool log_uart_msg_ { false }; // uart message variables - std::vector response_message_; std::vector request_message_; std::vector command_message_; uint8_t response_payload_length_;