Minor changes

This commit is contained in:
ElVit 2025-02-03 14:31:44 +01:00
parent 772860d353
commit 71c1eaf8ce
5 changed files with 23 additions and 20 deletions

View File

@ -5,10 +5,10 @@ namespace esphome
{
namespace panasonic_heatpump
{
const uint8_t PanasonicCommand::InitialMessage[REQUEST_INITIAL_SIZE] = {
const uint8_t PanasonicCommand::InitialMessage[REQUEST_INIT_MSG_SIZE] = {
0x31, 0x05, 0x10, 0x01, 0x00, 0x00, 0x00, 0xB9
};
const uint8_t PanasonicCommand::PeriodicalMessage[REQUEST_DATA_SIZE] = {
const uint8_t PanasonicCommand::PeriodicalMessage[REQUEST_DATA_MSG_SIZE] = {
0x71, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -18,7 +18,7 @@ namespace esphome
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x12
};
const uint8_t PanasonicCommand::CommandMessage[REQUEST_DATA_SIZE] = {
const uint8_t PanasonicCommand::CommandMessage[REQUEST_DATA_MSG_SIZE] = {
0xF1, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View File

@ -2,9 +2,9 @@
#include <cmath>
#include <vector>
#define REQUEST_INITIAL_SIZE 8
#define REQUEST_DATA_SIZE 111
#define REQUEST_OPTIONAL_SIZE 20
#define REQUEST_INIT_MSG_SIZE 8
#define REQUEST_DATA_MSG_SIZE 111
#define REQUEST_OPTIONAL_MSG_SIZE 20
namespace esphome
@ -31,9 +31,9 @@ namespace esphome
static uint8_t setByte6(uint8_t byte6, int val, int base, int bit);
static uint8_t setDemandControl(size_t input);
static const uint8_t InitialMessage[REQUEST_INITIAL_SIZE];
static const uint8_t PeriodicalMessage[REQUEST_DATA_SIZE];
static const uint8_t CommandMessage[REQUEST_DATA_SIZE];
static const uint8_t InitialMessage[REQUEST_INIT_MSG_SIZE];
static const uint8_t PeriodicalMessage[REQUEST_DATA_MSG_SIZE];
static const uint8_t CommandMessage[REQUEST_DATA_MSG_SIZE];
};
} // namespace panasonic_heatpump
} // namespace esphome

View File

@ -26,7 +26,7 @@ namespace esphome
constexpr const char* const PanasonicDecode::Bivalent[];
constexpr const char* const PanasonicDecode::ModelNames[];
// stores the bytes #129 to #138 of known models in the same order as the ModelNames above
// stores the bytes #129 to #138 of known models in the same order as the ModelNames
static const uint8_t KnownModels[NUMBER_OF_MODELS][10] =
{
0xE2, 0xCF, 0x0B, 0x13, 0x33, 0x32, 0xD1, 0x0C, 0x16, 0x33, // 0
@ -177,7 +177,8 @@ namespace esphome
uint16_t value = static_cast<uint16_t>((input2 << 8) | input1);
return (value - 1);
}
// TOP127, TOP128 //
float PanasonicDecode::getValvePID(uint8_t input)
{
return (((float)input - 1) / 2);

View File

@ -3,6 +3,7 @@
#include <string>
#include <vector>
#define RESPONSE_MSG_SIZE 203
#define NUMBER_OF_MODELS 53

View File

@ -1,8 +1,5 @@
#include "panasonic_heatpump.h"
#define response_message_SIZE 203
#define request_message_SIZE 111
namespace esphome
{
@ -341,9 +338,9 @@ namespace esphome
// payload_length: payload_length + 3 = packet_length
// checksum: if (sum(all bytes) & 0xFF == 0) ==> valid packet
if (bytes.size() != response_message_SIZE)
if (bytes.size() != RESPONSE_MSG_SIZE)
{
ESP_LOGW(TAG, "Invalid response message length: recieved %d - expected %d", bytes.size(), response_message_SIZE);
ESP_LOGW(TAG, "Invalid response message length: recieved %d - expected %d", bytes.size(), RESPONSE_MSG_SIZE);
delay(10);
return;
}
@ -511,7 +508,7 @@ namespace esphome
void PanasonicHeatpumpComponent::send_initial_message()
{
// send command
this->uart_hp_->write_array(PanasonicCommand::InitialMessage, REQUEST_INITIAL_SIZE);
this->uart_hp_->write_array(PanasonicCommand::InitialMessage, REQUEST_INIT_MSG_SIZE);
this->log_uart_hex(">>>", this->command_message_, ',');
delay(100); // NOLINT
}
@ -519,7 +516,7 @@ namespace esphome
void PanasonicHeatpumpComponent::send_periodical_message()
{
// send command
this->uart_hp_->write_array(PanasonicCommand::PeriodicalMessage, REQUEST_DATA_SIZE);
this->uart_hp_->write_array(PanasonicCommand::PeriodicalMessage, REQUEST_DATA_MSG_SIZE);
this->log_uart_hex(">>>", this->command_message_, ',');
delay(100); // NOLINT
}
@ -529,13 +526,17 @@ namespace esphome
// initialize the command
command_message_.clear();
command_message_.insert(this->command_message_.end(), PanasonicCommand::CommandMessage,
PanasonicCommand::CommandMessage + REQUEST_DATA_SIZE);
PanasonicCommand::CommandMessage + REQUEST_DATA_MSG_SIZE);
// set command byte
command_message_[index] = value;
// calculate and set set checksum (last element)
command_message_.back() = PanasonicCommand::calcChecksum(command_message_, command_message_.size() - 1);
// ToDo: Wait until no request is send or stop periodic message.
// while (request_receiving_ == 1) { delay(1); }
// send command
this->uart_hp_->write_array(this->command_message_);
// this->uart_hp_->write_array(this->command_message_);
this->log_uart_hex(">>>", this->command_message_, ',');
delay(100); // NOLINT
}