Added 10ms delay after log msg. Accept also init message in read_response and read_request.

This commit is contained in:
ElVit
2025-02-15 22:13:18 +01:00
parent c3e9f30b1f
commit b148b465f4
8 changed files with 22 additions and 12 deletions
@@ -11,6 +11,7 @@ namespace esphome
void PanasonicHeatpumpBinarySensor::dump_config()
{
LOG_BINARY_SENSOR("", "Panasonic Heatpump Binary Sensor", this);
delay(10);
}
} // namespace panasonic_heatpump
} // namespace esphome
@@ -11,6 +11,7 @@ namespace esphome
void PanasonicHeatpumpNumber::dump_config()
{
LOG_NUMBER("", "Panasonic Heatpump Number", this);
delay(10);
}
void PanasonicHeatpumpNumber::control(float value)
@@ -10,6 +10,7 @@ namespace esphome
void PanasonicHeatpumpComponent::dump_config()
{
ESP_LOGCONFIG(TAG, "Panasonic Heatpump");
delay(10);
}
void PanasonicHeatpumpComponent::setup()
@@ -52,7 +53,7 @@ namespace esphome
// Message shall start with 0x71, if not skip this byte
if (!this->response_receiving_)
{
if (byte != 0x71)
if (byte != 0x31 && byte != 0x71 && byte != 0xF1)
continue;
this->response_receiving_ = true;
}
@@ -63,11 +64,11 @@ namespace esphome
if (this->response_message_.size() == 2)
this->response_payload_length_ = byte;
// Discard message if format is wrong
if (this->response_message_.size() == 3 && byte != 0x01 ||
this->response_message_.size() == 4 && byte != 0x10)
if ((this->response_message_.size() == 3 || this->response_message_.size() == 4)
&& byte != 0x01 && byte != 0x10)
{
ESP_LOGW(TAG, "Invalid response message: %d. byte is 0x%02X but expexted is 0x%02X",
response_message_.size(), byte, response_message_.size() == 3 ? "01" : "10");
ESP_LOGW(TAG, "Invalid response message: %d. byte is 0x%02X but expexted is 0x01 or 0x10",
response_message_.size(), byte);
delay(10);
this->response_message_.clear();
this->response_receiving_ = false;
@@ -128,7 +129,7 @@ namespace esphome
// Message shall start with 0x71 or 0xF1, if not skip this byte
if (!this->request_receiving_)
{
if (byte != 0x71 && byte != 0xF1)
if (byte != 0x31 && byte != 0x71 && byte != 0xF1)
continue;
this->request_receiving_ = true;
}
@@ -140,11 +141,11 @@ namespace esphome
this->request_payload_length_ = byte;
// Discard message if format is wrong
if (this->request_message_.size() == 3 && byte != 0x01 ||
this->request_message_.size() == 4 && byte != 0x10)
if ((this->request_message_.size() == 3 || this->request_message_.size() == 4)
&& byte != 0x01 && byte != 0x10)
{
ESP_LOGW(TAG, "Invalid request message: %d. byte is 0x%02X but expexted is 0x%02X",
request_message_.size(), byte, request_message_.size() == 3 ? "01" : "10");
ESP_LOGW(TAG, "Invalid request message: %d. byte is 0x%02X but expexted is 0x01 or 0x10",
request_message_.size(), byte);
delay(10);
this->request_message_.clear();
this->request_receiving_ = false;
@@ -244,7 +244,7 @@ namespace esphome
SUB_SWITCH(set33);
SUB_SWITCH(set34);
void switch_control(switch_::Switch* object, size_t value);
void control_switch(switch_::Switch* object, size_t value);
#endif
PanasonicHeatpumpComponent() = default;
@@ -284,7 +284,10 @@ namespace esphome
void publish_number(std::vector<uint8_t> bytes);
void publish_select(std::vector<uint8_t> bytes);
void publish_switch(std::vector<uint8_t> bytes);
void log_uart_hex(std::string prefix, const std::vector<uint8_t> &data, uint8_t separator) { this->log_uart_hex(prefix, &data[0], data.size(), separator); }
void log_uart_hex(std::string prefix, const std::vector<uint8_t> &data, uint8_t separator)
{
this->log_uart_hex(prefix, &data[0], data.size(), separator);
}
void log_uart_hex(std::string prefix, const uint8_t *data, size_t length, uint8_t separator);
};
} // namespace panasonic_heatpump
@@ -11,6 +11,7 @@ namespace esphome
void PanasonicHeatpumpSelect::dump_config()
{
LOG_SELECT("", "Panasonic Heatpump Select", this);
delay(10);
}
void PanasonicHeatpumpSelect::control(const std::string &value)
@@ -11,6 +11,7 @@ namespace esphome
void PanasonicHeatpumpSensor::dump_config()
{
LOG_SENSOR("", "Panasonic Heatpump Sensor", this);
delay(10);
}
} // namespace panasonic_heatpump
} // namespace esphome
@@ -11,6 +11,7 @@ namespace esphome
void PanasonicHeatpumpSwitch::dump_config()
{
LOG_SWITCH("", "Panasonic Heatpump Switch", this);
delay(10);
}
void PanasonicHeatpumpSwitch::write_state(bool state)
@@ -11,6 +11,7 @@ namespace esphome
void PanasonicHeatpumpTextSensor::dump_config()
{
LOG_TEXT_SENSOR("", "Panasonic Heatpump Text Sensor", this);
delay(10);
}
} // namespace panasonic_heatpump
} // namespace esphome