Merge pull request #12 from ElVit/panasonic_dev

This commit is contained in:
ElVit 2025-07-23 13:22:23 +02:00 committed by GitHub
commit 795d705aba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 229 additions and 578 deletions

View File

@ -21,143 +21,97 @@ namespace esphome
switch (this->id_)
{
case BinarySensorIds::CONF_TOP0:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[4]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP2:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[4]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP3:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[7]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP13:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[5]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP26:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[111]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP60:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[112]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP61:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[112]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP68:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[5]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP69:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[117]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP99:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[24]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP100:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[24]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP108:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(data[20]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP109:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[20]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP110:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[20]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP119:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[23]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP120:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[23]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP121:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(data[23]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP122:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[23]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP123:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[116]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP124:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(data[116]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP129:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[26]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP132:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(data[26]));
if (this->has_state() && this->state == new_state) return;
break;
}
case BinarySensorIds::CONF_TOP133:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[26]));
if (this->has_state() && this->state == new_state) return;
break;
}
default: return;
};

View File

@ -24,6 +24,16 @@ 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::PollingExtraMessage[DATA_MESSAGE_SIZE] = {
0x71, 0x6C, 0x01, 0x21, 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,
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, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
const uint8_t PanasonicCommand::CommandMessage[DATA_MESSAGE_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,

View File

@ -42,6 +42,7 @@ namespace esphome
static const uint8_t InitialRequest[INIT_REQUEST_SIZE];
static const uint8_t InitialResponse[INIT_RESPONSE_SIZE];
static const uint8_t PollingMessage[DATA_MESSAGE_SIZE];
static const uint8_t PollingExtraMessage[DATA_MESSAGE_SIZE];
static const uint8_t CommandMessage[DATA_MESSAGE_SIZE];
};
} // namespace panasonic_heatpump

View File

@ -24,6 +24,7 @@ namespace esphome
break;
case 0x71:
msgType = "polling_" + msgType;
if (data[3] == 0x21) msgType = "extra_" + msgType;
break;
case 0xF1:
msgType = "command_" + msgType;

View File

@ -18,172 +18,107 @@ namespace esphome
switch (this->id_)
{
case NumberIds::CONF_SET5:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 38);
break;
}
case NumberIds::CONF_SET6:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 39);
break;
}
case NumberIds::CONF_SET7:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 40);
break;
}
case NumberIds::CONF_SET8:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 41);
break;
}
case NumberIds::CONF_SET11:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 42);
break;
}
case NumberIds::CONF_SET15:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1(value), 45);
break;
}
case NumberIds::CONF_SET16_01:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 75);
break;
}
case NumberIds::CONF_SET16_02:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 76);
break;
}
case NumberIds::CONF_SET16_03:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 77);
break;
}
case NumberIds::CONF_SET16_04:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 78);
break;
}
case NumberIds::CONF_SET16_05:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 79);
break;
}
case NumberIds::CONF_SET16_06:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 80);
break;
}
case NumberIds::CONF_SET16_07:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 81);
break;
}
case NumberIds::CONF_SET16_08:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 82);
break;
}
case NumberIds::CONF_SET16_09:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 86);
break;
}
case NumberIds::CONF_SET16_10:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 87);
break;
}
case NumberIds::CONF_SET16_11:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 88);
break;
}
case NumberIds::CONF_SET16_12:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 89);
break;
}
case NumberIds::CONF_SET16_13:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 90);
break;
}
case NumberIds::CONF_SET16_14:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 91);
break;
}
case NumberIds::CONF_SET16_15:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 92);
break;
}
case NumberIds::CONF_SET16_16:
{
this->parent_->set_command_curve(PanasonicCommand::setPlus128(value), 93);
break;
}
case NumberIds::CONF_SET18:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 84);
break;
}
case NumberIds::CONF_SET19:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 94);
break;
}
case NumberIds::CONF_SET20:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 99);
break;
}
case NumberIds::CONF_SET21:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1(value), 104);
break;
}
case NumberIds::CONF_SET22:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 105);
break;
}
case NumberIds::CONF_SET23:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 106);
break;
}
case NumberIds::CONF_SET27:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 59);
break;
}
case NumberIds::CONF_SET29:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 83);
break;
}
case NumberIds::CONF_SET36:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 65);
break;
}
case NumberIds::CONF_SET37:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 66);
break;
}
case NumberIds::CONF_SET38:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus128(value), 68);
break;
}
default: return;
};
this->publish_state(state);
this->keep_state_ = 2;
}
@ -201,203 +136,137 @@ namespace esphome
switch (this->id_)
{
case NumberIds::CONF_SET11:
{
new_state = PanasonicDecode::getByteMinus128(data[42]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET20:
{
new_state = PanasonicDecode::getByteMinus128(data[99]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET18:
{
new_state = PanasonicDecode::getByteMinus128(data[84]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET19:
{
new_state = PanasonicDecode::getByteMinus128(data[94]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET5:
{
new_state = PanasonicDecode::getByteMinus128(data[38]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET6:
{
new_state = PanasonicDecode::getByteMinus128(data[39]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_01:
{
new_state = PanasonicDecode::getByteMinus128(data[75]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_02:
{
new_state = PanasonicDecode::getByteMinus128(data[76]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_04:
{
new_state = PanasonicDecode::getByteMinus128(data[78]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_03:
{
new_state = PanasonicDecode::getByteMinus128(data[77]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET7:
{
new_state = PanasonicDecode::getByteMinus128(data[40]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET8:
{
new_state = PanasonicDecode::getByteMinus128(data[41]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_09:
{
new_state = PanasonicDecode::getByteMinus128(data[86]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_10:
{
new_state = PanasonicDecode::getByteMinus128(data[87]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_12:
{
new_state = PanasonicDecode::getByteMinus128(data[89]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_11:
{
new_state = PanasonicDecode::getByteMinus128(data[88]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET29:
{
new_state = PanasonicDecode::getByteMinus128(data[83]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_05:
{
new_state = PanasonicDecode::getByteMinus128(data[79]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_06:
{
new_state = PanasonicDecode::getByteMinus128(data[80]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_08:
{
new_state = PanasonicDecode::getByteMinus128(data[82]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_07:
{
new_state = PanasonicDecode::getByteMinus128(data[81]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_13:
{
new_state = PanasonicDecode::getByteMinus128(data[90]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_14:
{
new_state = PanasonicDecode::getByteMinus128(data[91]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_16:
{
new_state = PanasonicDecode::getByteMinus128(data[93]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET16_15:
{
new_state = PanasonicDecode::getByteMinus128(data[92]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET15:
{
new_state = PanasonicDecode::getByteMinus1(data[45]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET21:
{
new_state = PanasonicDecode::getByteMinus1(data[104]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET22:
{
new_state = PanasonicDecode::getByteMinus128(data[105]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET23:
{
new_state = PanasonicDecode::getByteMinus128(data[106]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET27:
{
new_state = PanasonicDecode::getByteMinus128(data[59]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET36:
{
new_state = PanasonicDecode::getByteMinus128(data[65]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET37:
{
new_state = PanasonicDecode::getByteMinus128(data[66]);
if (this->has_state() && this->state == new_state) return;
break;
}
case NumberIds::CONF_SET38:
{
new_state = PanasonicDecode::getByteMinus128(data[68]);
if (this->has_state() && this->state == new_state) return;
break;
}
default: return;
};

View File

@ -10,7 +10,7 @@ namespace esphome
void PanasonicHeatpumpComponent::dump_config()
{
ESP_LOGCONFIG(TAG, "Panasonic Heatpump");
ESP_LOGW(TAG, "*** Panasonic Heatpump Component v0.0.4 ***");
delay(10); // NOLINT
}
@ -25,8 +25,8 @@ namespace esphome
void PanasonicHeatpumpComponent::update()
{
if (this->uart_client_ == nullptr)
this->next_request_ = RequestType::POLLING;
if (this->uart_client_ != nullptr) return;
this->next_request_ = this->send_extra_request_ ? RequestType::POLLING_EXTRA : RequestType::POLLING;
}
void PanasonicHeatpumpComponent::loop()
@ -34,98 +34,91 @@ namespace esphome
switch (this->loop_state_)
{
case LoopState::READ_RESPONSE:
{
this->read_response();
this->loop_state_ = LoopState::CHECK_RESPONSE;
break;
}
case LoopState::CHECK_RESPONSE:
this->current_response_ = this->check_response(this->response_message_);
switch (this->current_response_)
{
bool result = this->check_response(this->heatpump_message_);
this->loop_state_ = result ?
LoopState::PUBLISH_SENSOR : LoopState::SEND_REQUEST;
case ResponseType::UNKNOWN:
this->loop_state_ = LoopState::SEND_REQUEST;
break;
case ResponseType::DEFAULT:
this->loop_state_ = LoopState::PUBLISH_SENSOR;
break;
case ResponseType::EXTRA:
this->loop_state_ = LoopState::PUBLISH_EXTRA_SENSOR;
break;
};
break;
}
case LoopState::PUBLISH_SENSOR:
{
for (auto *entity : this->sensors_)
{
entity->publish_new_state(this->heatpump_message_);
entity->publish_new_state(this->heatpump_default_message_);
}
this->loop_state_ = LoopState::PUBLISH_BINARY_SENSOR;
break;
}
case LoopState::PUBLISH_BINARY_SENSOR:
{
for (auto *entity : this->binary_sensors_)
{
entity->publish_new_state(this->heatpump_message_);
entity->publish_new_state(this->heatpump_default_message_);
}
this->loop_state_ = LoopState::PUBLISH_TEXT_SENSOR;
break;
}
case LoopState::PUBLISH_TEXT_SENSOR:
{
for (auto *entity : this->text_sensors_)
{
entity->publish_new_state(this->heatpump_message_);
entity->publish_new_state(this->heatpump_default_message_);
}
this->loop_state_ = LoopState::PUBLISH_NUMBER;
break;
}
case LoopState::PUBLISH_NUMBER:
{
for (auto *entity : this->numbers_)
{
entity->publish_new_state(this->heatpump_message_);
entity->publish_new_state(this->heatpump_default_message_);
}
this->loop_state_ = LoopState::PUBLISH_SELECT;
break;
}
case LoopState::PUBLISH_SELECT:
{
for (auto *entity : this->selects_)
{
entity->publish_new_state(this->heatpump_message_);
entity->publish_new_state(this->heatpump_default_message_);
}
this->loop_state_ = LoopState::PUBLISH_SWITCH;
break;
}
case LoopState::PUBLISH_SWITCH:
{
for (auto *entity : this->switches_)
{
entity->publish_new_state(this->heatpump_message_);
entity->publish_new_state(this->heatpump_default_message_);
}
this->loop_state_ = LoopState::PUBLISH_CLIMATE;
break;
}
case LoopState::PUBLISH_CLIMATE:
{
for (auto *entity : this->climates_)
{
entity->publish_new_state(this->heatpump_message_);
entity->publish_new_state(this->heatpump_default_message_);
}
this->loop_state_ = LoopState::SEND_REQUEST;
break;
}
case LoopState::SEND_REQUEST:
case LoopState::PUBLISH_EXTRA_SENSOR:
for (auto *entity : this->extra_sensors_)
{
entity->publish_new_state(this->heatpump_extra_message_);
}
this->loop_state_ = LoopState::SEND_REQUEST;
break;
case LoopState::SEND_REQUEST:
this->send_request(this->next_request_);
this->loop_state_ = LoopState::READ_REQUEST;
break;
}
case LoopState::READ_REQUEST:
{
this->read_request();
this->loop_state_ = LoopState::RESTART_LOOP;
break;
}
default:
{
this->loop_state_ = LoopState::READ_RESPONSE;
break;
}
};
}
@ -156,12 +149,11 @@ namespace esphome
this->payload_length_ = byte_;
}
// Discard message if format is wrong
if ((this->response_message_.size() == 3 ||
this->response_message_.size() == 4) &&
byte_ != 0x01 && byte_ != 0x10 && byte_ != 0x21)
if ((this->response_message_.size() == 3 && byte_ != 0x01 && byte_ != 0x10) ||
(this->response_message_.size() == 4 && byte_ != 0x10 && byte_ != 0x21))
{
this->response_receiving_ = false;
ESP_LOGW(TAG, "Invalid response message: %d. byte is 0x%02X but expexted is 0x01 or 0x10",
ESP_LOGW(TAG, "Invalid response message: %d. byte is 0x%02X but expexted is 0x01, 0x10 or 0x21",
response_message_.size(), byte_);
delay(10); // NOLINT
continue;
@ -171,7 +163,6 @@ namespace esphome
if (this->response_message_.size() > 2 &&
this->response_message_.size() == this->payload_length_ + 3)
{
this->heatpump_message_ = this->response_message_;
this->response_receiving_ = false;
this->current_response_count_++;
if (this->log_uart_msg_) PanasonicHelpers::log_uart_hex(UART_LOG_RX, this->response_message_, ',');
@ -184,27 +175,26 @@ namespace esphome
switch (requestType)
{
case RequestType::COMMAND:
{
if (this->log_uart_msg_) PanasonicHelpers::log_uart_hex(UART_LOG_TX, this->command_message_, ',');
this->write_array(this->command_message_);
this->flush();
break;
}
case RequestType::INITIAL:
{
// Probably not necessary but CZ-TAW1 sends this query on boot
if (this->log_uart_msg_) PanasonicHelpers::log_uart_hex(UART_LOG_TX, PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE, ',');
this->write_array(PanasonicCommand::InitialRequest, INIT_REQUEST_SIZE);
this->flush();
break;
}
case RequestType::POLLING:
{
if (this->log_uart_msg_) PanasonicHelpers::log_uart_hex(UART_LOG_TX, PanasonicCommand::PollingMessage, DATA_MESSAGE_SIZE, ',');
this->write_array(PanasonicCommand::PollingMessage, DATA_MESSAGE_SIZE);
this->flush();
break;
}
case RequestType::POLLING_EXTRA:
if (this->log_uart_msg_) PanasonicHelpers::log_uart_hex(UART_LOG_TX, PanasonicCommand::PollingExtraMessage, DATA_MESSAGE_SIZE, ',');
this->write_array(PanasonicCommand::PollingExtraMessage, DATA_MESSAGE_SIZE);
this->flush();
break;
};
this->next_request_ = RequestType::NONE;
@ -236,12 +226,11 @@ namespace esphome
this->payload_length_ = byte_;
}
// Discard message if format is wrong
if ((this->request_message_.size() == 3 ||
this->request_message_.size() == 4) &&
byte_ != 0x01 && byte_ != 0x10 && byte_ != 0x21)
if ((this->request_message_.size() == 3 && byte_ != 0x01 && byte_ != 0x10) ||
(this->request_message_.size() == 4 && byte_ != 0x10 && byte_ != 0x21))
{
this->request_receiving_ = false;
ESP_LOGW(TAG, "Invalid request message: %d. byte is 0x%02X but expexted is 0x01 or 0x10",
ESP_LOGW(TAG, "Invalid request message: %d. byte is 0x%02X but expexted is 0x01, 0x10 or 0x21",
request_message_.size(), byte_);
delay(10); // NOLINT
continue;
@ -259,46 +248,74 @@ namespace esphome
int PanasonicHeatpumpComponent::getResponseByte(const int index)
{
if (this->heatpump_message_.size() > index) return this->heatpump_message_[index];
if (this->response_message_.size() > index) return this->response_message_[index];
if (this->heatpump_default_message_.size() > index) return this->heatpump_default_message_[index];
return -1;
}
bool PanasonicHeatpumpComponent::check_response(const std::vector<uint8_t>& data)
int PanasonicHeatpumpComponent::getExtraResponseByte(const int index)
{
if (this->heatpump_extra_message_.size() > index) return this->heatpump_extra_message_[index];
return -1;
}
ResponseType PanasonicHeatpumpComponent::check_response(const std::vector<uint8_t>& data)
{
// Read response message:
// format: 0x71 [payload_length] 0x01 0x10 [[TOP0 - TOP114] ...] 0x00 [checksum]
// format: 0x71 [payload_length] 0x01 [0x10 || 0x21] [[TOP0 - TOP114] ...] 0x00 [checksum]
// payload_length: payload_length + 3 = packet_length
// checksum: if (sum(all bytes) & 0xFF == 0) ==> valid packet
if (data.empty()) return false;
if (data[0] != 0x71) return false;
if (data[3] != 0x10) return false;
if (data.empty()) return ResponseType::UNKNOWN;
if (data[0] != 0x71) return ResponseType::UNKNOWN;
if (this->response_receiving_) return ResponseType::UNKNOWN;
if (data.size() != RESPONSE_MSG_SIZE)
{
ESP_LOGW(TAG, "Invalid response message length: recieved %d - expected %d", data.size(), RESPONSE_MSG_SIZE);
delay(10); // NOLINT
return false;
return ResponseType::UNKNOWN;
}
// Verify checksum
uint8_t checksum = 0;
for (int i = 0; i < data.size(); i++)
{
checksum += data[i];
}
// checksum = checksum & 0xFF;
// all bytes (including checksum byte) shall be 0x00
if (checksum != 0)
{
ESP_LOGW(TAG, "Invalid response message: checksum = 0x%02X, last_byte = 0x%02X", checksum, data[202]);
delay(10); // NOLINT
return false;
return ResponseType::UNKNOWN;
}
this->send_extra_request_ = data[3] == 0x10 && data[199] > 0x02 &&
this->send_extra_request_ == false ? true : false;
// Get response type and save the response
auto responseType = ResponseType::UNKNOWN;
if (data[3] == 0x10)
{
responseType = ResponseType::DEFAULT;
this->heatpump_default_message_ = data;
}
else if (data[3] == 0x21)
{
responseType = ResponseType::EXTRA;
this->heatpump_extra_message_ = data;
}
if (responseType == ResponseType::UNKNOWN)
{
ESP_LOGW(TAG, "Unknown response type (4. byte): 0x%02X. Expected 0x10 or 0x21.", data[3]);
delay(10); // NOLINT
return responseType;
}
// Check if the current response is a new response
if (this->last_response_count_ == this->current_response_count_) return false;
if (this->last_response_count_ == this->current_response_count_) return ResponseType::UNKNOWN;
this->last_response_count_ = this->current_response_count_;
return true;
return responseType;
}
void PanasonicHeatpumpComponent::set_command_high_nibble(const uint8_t value, const uint8_t index)
@ -309,7 +326,7 @@ namespace esphome
this->command_message_.assign(std::begin(PanasonicCommand::CommandMessage),
std::end(PanasonicCommand::CommandMessage));
}
uint8_t lowNibble = this->heatpump_message_[index] & 0b1111;
uint8_t lowNibble = this->heatpump_default_message_[index] & 0b1111;
uint8_t highNibble = value << 4;
// set command byte
this->command_message_[index] = highNibble + lowNibble;
@ -328,7 +345,7 @@ namespace esphome
this->command_message_.assign(std::begin(PanasonicCommand::CommandMessage),
std::end(PanasonicCommand::CommandMessage));
}
uint8_t highNibble = this->heatpump_message_[index] & 0b11110000;
uint8_t highNibble = this->heatpump_default_message_[index] & 0b11110000;
uint8_t lowNibble = value & 0b1111;
// set command byte
this->command_message_[index] = highNibble + lowNibble;
@ -369,27 +386,27 @@ namespace esphome
if (index == 75 || index == 76 || index == 77 || index == 78 ||
index == 86 || index == 87 || index == 88 || index == 89)
{
this->command_message_[75] = this->heatpump_message_[75];
this->command_message_[76] = this->heatpump_message_[76];
this->command_message_[77] = this->heatpump_message_[77];
this->command_message_[78] = this->heatpump_message_[78];
this->command_message_[86] = this->heatpump_message_[86];
this->command_message_[87] = this->heatpump_message_[87];
this->command_message_[88] = this->heatpump_message_[88];
this->command_message_[89] = this->heatpump_message_[89];
this->command_message_[75] = this->heatpump_default_message_[75];
this->command_message_[76] = this->heatpump_default_message_[76];
this->command_message_[77] = this->heatpump_default_message_[77];
this->command_message_[78] = this->heatpump_default_message_[78];
this->command_message_[86] = this->heatpump_default_message_[86];
this->command_message_[87] = this->heatpump_default_message_[87];
this->command_message_[88] = this->heatpump_default_message_[88];
this->command_message_[89] = this->heatpump_default_message_[89];
}
// Set zone 2 curve bytes
if (index == 79 || index == 80 || index == 81 || index == 82 ||
index == 90 || index == 91 || index == 92 || index == 93)
{
this->command_message_[79] = this->heatpump_message_[79];
this->command_message_[80] = this->heatpump_message_[80];
this->command_message_[81] = this->heatpump_message_[81];
this->command_message_[82] = this->heatpump_message_[82];
this->command_message_[90] = this->heatpump_message_[90];
this->command_message_[91] = this->heatpump_message_[91];
this->command_message_[92] = this->heatpump_message_[92];
this->command_message_[93] = this->heatpump_message_[93];
this->command_message_[79] = this->heatpump_default_message_[79];
this->command_message_[80] = this->heatpump_default_message_[80];
this->command_message_[81] = this->heatpump_default_message_[81];
this->command_message_[82] = this->heatpump_default_message_[82];
this->command_message_[90] = this->heatpump_default_message_[90];
this->command_message_[91] = this->heatpump_default_message_[91];
this->command_message_[92] = this->heatpump_default_message_[92];
this->command_message_[93] = this->heatpump_default_message_[93];
}
// set command byte

View File

@ -27,17 +27,26 @@ namespace esphome
PUBLISH_SELECT,
PUBLISH_SWITCH,
PUBLISH_CLIMATE,
PUBLISH_EXTRA_SENSOR,
SEND_REQUEST,
READ_REQUEST,
RESTART_LOOP
RESTART_LOOP,
};
enum RequestType : uint8_t
{
NONE,
COMMAND,
INITIAL,
POLLING,
COMMAND,
NONE
POLLING_EXTRA,
};
enum ResponseType : uint8_t
{
UNKNOWN,
DEFAULT,
EXTRA,
};
class PanasonicHeatpumpEntity
@ -66,6 +75,7 @@ namespace esphome
void set_log_uart_msg(bool active) { this->log_uart_msg_ = active; }
// uart message variables to use in lambda functions
int getResponseByte(const int index);
int getExtraResponseByte(const int index);
// command functions
void set_command_high_nibble(const uint8_t value, const uint8_t index);
void set_command_low_nibble(const uint8_t value, const uint8_t index);
@ -79,13 +89,15 @@ namespace esphome
void add_sensor(PanasonicHeatpumpEntity *sensor) { sensors_.push_back(sensor); }
void add_switch(PanasonicHeatpumpEntity *switch_) { switches_.push_back(switch_); }
void add_text_sensor(PanasonicHeatpumpEntity *text_sensor) { text_sensors_.push_back(text_sensor); }
void add_extra_sensor(PanasonicHeatpumpEntity *sensor) { extra_sensors_.push_back(sensor); }
protected:
// options variables
uart::UARTComponent* uart_client_ { nullptr };
bool log_uart_msg_ { false };
// uart message variables
std::vector<uint8_t> heatpump_message_;
std::vector<uint8_t> heatpump_default_message_;
std::vector<uint8_t> heatpump_extra_message_;
std::vector<uint8_t> response_message_;
std::vector<uint8_t> request_message_;
std::vector<uint8_t> command_message_;
@ -95,8 +107,10 @@ namespace esphome
uint8_t last_response_count_ { 0 };
bool response_receiving_ { false };
bool request_receiving_ { false };
RequestType next_request_ { RequestType::INITIAL };
bool send_extra_request_ { false };
LoopState loop_state_ { LoopState::RESTART_LOOP };
RequestType next_request_ { RequestType::INITIAL };
ResponseType current_response_ { ResponseType::UNKNOWN };
// entity vectors
std::vector<PanasonicHeatpumpEntity *> binary_sensors_;
std::vector<PanasonicHeatpumpEntity *> climates_;
@ -105,12 +119,13 @@ namespace esphome
std::vector<PanasonicHeatpumpEntity *> sensors_;
std::vector<PanasonicHeatpumpEntity *> switches_;
std::vector<PanasonicHeatpumpEntity *> text_sensors_;
std::vector<PanasonicHeatpumpEntity *> extra_sensors_;
// uart message functions
void read_response();
void send_request(RequestType requestType);
void read_request();
bool check_response(const std::vector<uint8_t>& data);
ResponseType check_response(const std::vector<uint8_t>& data);
};
} // namespace panasonic_heatpump
} // namespace esphome

View File

@ -22,42 +22,29 @@ namespace esphome
switch (this->id_)
{
case SelectIds::CONF_SET2:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply16(index), 5);
break;
}
case SelectIds::CONF_SET3:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply8(index), 7);
break;
}
case SelectIds::CONF_SET4:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1(index), 7);
break;
}
case SelectIds::CONF_SET9:
{
this->parent_->set_command_byte(PanasonicCommand::setOperationMode(index), 6);
break;
}
case SelectIds::CONF_SET17:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply64(index), 6);
break;
}
case SelectIds::CONF_SET26:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply16(index), 25);
break;
}
case SelectIds::CONF_SET35:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply4(index), 26);
break;
}
default: return;
};
this->publish_state(value);
this->keep_state_ = 2;
}
@ -75,47 +62,33 @@ namespace esphome
switch (this->id_)
{
case SelectIds::CONF_SET9:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::OperationMode, PanasonicDecode::getOperationMode(data[6]));
if (this->has_state() && this->state == 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;
break;
}
case SelectIds::CONF_SET3:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::QuietMode, PanasonicDecode::getBit3and4and5(data[7]));
if (this->has_state() && this->state == 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;
break;
}
case SelectIds::CONF_SET17:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ZoneState, PanasonicDecode::getBit1and2(data[6]));
if (this->has_state() && this->state == 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;
break;
}
case SelectIds::CONF_SET35:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::BivalentMode, PanasonicDecode::getBit5and6(data[26]));
if (this->has_state() && this->state == new_state) return;
break;
}
default: return;
};

View File

@ -128,6 +128,13 @@ CONF_TOP136 = "top136" # Bivalent Advanced Start Delay
CONF_TOP137 = "top137" # Bivalent Advanced Stop Delay
CONF_TOP138 = "top138" # Bivalent Advanced DHW Delay
CONF_XTOP0 = "xtop0" # Heat Power Consumption Extra
CONF_XTOP1 = "xtop1" # Cool Power Consumption Extra
CONF_XTOP2 = "xtop2" # DHW Power Consumption Extra
CONF_XTOP3 = "xtop3" # Heat Power Production Extra
CONF_XTOP4 = "xtop4" # Cool Power Production Extra
CONF_XTOP5 = "xtop5" # DHW Power Production Extra
TYPES = [
CONF_TOP1,
CONF_TOP5,
@ -224,6 +231,13 @@ TYPES = [
CONF_TOP136,
CONF_TOP137,
CONF_TOP138,
CONF_XTOP0,
CONF_XTOP1,
CONF_XTOP2,
CONF_XTOP3,
CONF_XTOP4,
CONF_XTOP5,
]
PanasonicHeatpumpSensor = panasonic_heatpump_ns.class_("PanasonicHeatpumpSensor", sensor.Sensor, cg.Component)
@ -894,6 +908,49 @@ CONFIG_SCHEMA = cv.Schema(
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement = UNIT_MINUTE,
),
cv.Optional(CONF_XTOP0): sensor.sensor_schema(
PanasonicHeatpumpSensor,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement = UNIT_WATT,
),
cv.Optional(CONF_XTOP1): sensor.sensor_schema(
PanasonicHeatpumpSensor,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement = UNIT_WATT,
),
cv.Optional(CONF_XTOP2): sensor.sensor_schema(
PanasonicHeatpumpSensor,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement = UNIT_WATT,
),
cv.Optional(CONF_XTOP3): sensor.sensor_schema(
PanasonicHeatpumpSensor,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement = UNIT_WATT,
),
cv.Optional(CONF_XTOP4): sensor.sensor_schema(
PanasonicHeatpumpSensor,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement = UNIT_WATT,
),
cv.Optional(CONF_XTOP5): sensor.sensor_schema(
PanasonicHeatpumpSensor,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
unit_of_measurement = UNIT_WATT,
),
}
).extend(cv.COMPONENT_SCHEMA)
@ -905,4 +962,7 @@ async def to_code(config):
await cg.register_component(var, child_config)
cg.add(var.set_parent(parent))
cg.add(var.set_id(index))
if key.startswith("xtop"):
cg.add(parent.add_extra_sensor(var))
else:
cg.add(parent.add_sensor(var))

View File

@ -21,575 +21,410 @@ namespace esphome
switch (this->id_)
{
case SensorIds::CONF_TOP1:
{
new_state = PanasonicDecode::getPumpFlow(data, 169);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP5:
{
new_state = PanasonicDecode::getByteMinus128(data[143]) + PanasonicDecode::getFractional(data[118], 0);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP6:
{
new_state = PanasonicDecode::getByteMinus128(data[144]) + PanasonicDecode::getFractional(data[118], 3);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP7:
{
new_state = PanasonicDecode::getByteMinus128(data[153]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP8:
{
new_state = PanasonicDecode::getByteMinus1(data[166]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP9:
{
new_state = PanasonicDecode::getByteMinus128(data[42]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP10:
{
new_state = PanasonicDecode::getByteMinus128(data[141]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP11:
{
new_state = PanasonicDecode::getWordMinus1(data, 182);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP12:
{
new_state = PanasonicDecode::getWordMinus1(data, 179);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP14:
{
new_state = PanasonicDecode::getByteMinus128(data[142]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP15:
{
new_state = PanasonicDecode::getByteMinus1Times200(data[194]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP16:
{
new_state = PanasonicDecode::getByteMinus1Times200(data[193]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP21:
{
new_state = PanasonicDecode::getByteMinus128(data[158]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP22:
{
new_state = PanasonicDecode::getByteMinus128(data[99]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP23:
{
new_state = PanasonicDecode::getByteMinus128(data[84]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP24:
{
new_state = PanasonicDecode::getByteMinus128(data[94]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP25:
{
new_state = PanasonicDecode::getByteMinus128(data[44]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP27:
{
new_state = PanasonicDecode::getByteMinus128(data[38]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP28:
{
new_state = PanasonicDecode::getByteMinus128(data[39]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP29:
{
new_state = PanasonicDecode::getByteMinus128(data[75]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP30:
{
new_state = PanasonicDecode::getByteMinus128(data[76]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP31:
{
new_state = PanasonicDecode::getByteMinus128(data[78]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP32:
{
new_state = PanasonicDecode::getByteMinus128(data[77]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP33:
{
new_state = PanasonicDecode::getByteMinus128(data[156]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP34:
{
new_state = PanasonicDecode::getByteMinus128(data[40]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP35:
{
new_state = PanasonicDecode::getByteMinus128(data[41]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP36:
{
new_state = PanasonicDecode::getByteMinus128(data[145]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP37:
{
new_state = PanasonicDecode::getByteMinus128(data[146]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP38:
{
new_state = PanasonicDecode::getByteMinus1Times200(data[196]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP39:
{
new_state = PanasonicDecode::getByteMinus1Times200(data[195]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP40:
{
new_state = PanasonicDecode::getByteMinus1Times200(data[198]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP41:
{
new_state = PanasonicDecode::getByteMinus1Times200(data[197]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP42:
{
new_state = PanasonicDecode::getByteMinus128(data[147]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP43:
{
new_state = PanasonicDecode::getByteMinus128(data[148]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP45:
{
new_state = PanasonicDecode::getByteMinus128(data[43]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP46:
{
new_state = PanasonicDecode::getByteMinus128(data[149]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP47:
{
new_state = PanasonicDecode::getByteMinus128(data[150]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP48:
{
new_state = PanasonicDecode::getByteMinus128(data[151]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP49:
{
new_state = PanasonicDecode::getByteMinus128(data[154]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP50:
{
new_state = PanasonicDecode::getByteMinus128(data[155]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP51:
{
new_state = PanasonicDecode::getByteMinus128(data[157]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP52:
{
new_state = PanasonicDecode::getByteMinus128(data[159]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP53:
{
new_state = PanasonicDecode::getByteMinus128(data[160]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP54:
{
new_state = PanasonicDecode::getByteMinus128(data[161]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP55:
{
new_state = PanasonicDecode::getByteMinus128(data[162]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP56:
{
new_state = PanasonicDecode::getByteMinus128(data[139]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP57:
{
new_state = PanasonicDecode::getByteMinus128(data[140]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP62:
{
new_state = PanasonicDecode::getByteMinus1Times10(data[173]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP63:
{
new_state = PanasonicDecode::getByteMinus1Times10(data[174]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP64:
{
new_state = PanasonicDecode::getByteMinus1Div5(data[163]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP65:
{
new_state = PanasonicDecode::getByteMinus1Times50(data[171]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP66:
{
new_state = PanasonicDecode::getByteMinus1Times50(data[164]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP67:
{
new_state = PanasonicDecode::getByteMinus1Div5(data[165]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP70:
{
new_state = PanasonicDecode::getByteMinus128(data[100]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP71:
{
new_state = PanasonicDecode::getByteMinus1(data[101]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP72:
{
new_state = PanasonicDecode::getByteMinus128(data[86]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP73:
{
new_state = PanasonicDecode::getByteMinus128(data[87]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP74:
{
new_state = PanasonicDecode::getByteMinus128(data[89]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP75:
{
new_state = PanasonicDecode::getByteMinus128(data[88]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP77:
{
new_state = PanasonicDecode::getByteMinus128(data[83]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP78:
{
new_state = PanasonicDecode::getByteMinus128(data[85]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP79:
{
new_state = PanasonicDecode::getByteMinus128(data[95]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP80:
{
new_state = PanasonicDecode::getByteMinus128(data[96]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP82:
{
new_state = PanasonicDecode::getByteMinus128(data[79]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP83:
{
new_state = PanasonicDecode::getByteMinus128(data[80]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP84:
{
new_state = PanasonicDecode::getByteMinus128(data[82]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP85:
{
new_state = PanasonicDecode::getByteMinus128(data[81]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP86:
{
new_state = PanasonicDecode::getByteMinus128(data[90]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP87:
{
new_state = PanasonicDecode::getByteMinus128(data[91]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP88:
{
new_state = PanasonicDecode::getByteMinus128(data[93]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP89:
{
new_state = PanasonicDecode::getByteMinus128(data[92]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP90:
{
new_state = PanasonicDecode::getWordMinus1(data, 185);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP91:
{
new_state = PanasonicDecode::getWordMinus1(data, 188);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP93:
{
new_state = PanasonicDecode::getByteMinus1(data[172]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP95:
{
new_state = PanasonicDecode::getByteMinus1(data[45]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP96:
{
new_state = PanasonicDecode::getByteMinus1(data[104]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP97:
{
new_state = PanasonicDecode::getByteMinus128(data[105]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP98:
{
new_state = PanasonicDecode::getByteMinus128(data[106]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP102:
{
new_state = PanasonicDecode::getByteMinus128(data[61]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP103:
{
new_state = PanasonicDecode::getByteMinus128(data[62]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP104:
{
new_state = PanasonicDecode::getByteMinus128(data[63]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP105:
{
new_state = PanasonicDecode::getByteMinus128(data[64]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP113:
{
new_state = PanasonicDecode::getByteMinus128(data[59]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP115:
{
new_state = PanasonicDecode::getByteMinus1Div50(data[125]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP116:
{
new_state = PanasonicDecode::getByteMinus128(data[126]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP117:
{
new_state = PanasonicDecode::getByteMinus128(data[127]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP118:
{
new_state = PanasonicDecode::getByteMinus128(data[128]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP127:
{
new_state = PanasonicDecode::getByteMinus1Div2(data[177]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP128:
{
new_state = PanasonicDecode::getByteMinus1Div2(data[178]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP131:
{
new_state = PanasonicDecode::getByteMinus128(data[65]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP134:
{
new_state = PanasonicDecode::getByteMinus128(data[66]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP135:
{
new_state = PanasonicDecode::getByteMinus128(data[68]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP136:
{
new_state = PanasonicDecode::getByteMinus1(data[67]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP137:
{
new_state = PanasonicDecode::getByteMinus1(data[69]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_TOP138:
{
new_state = PanasonicDecode::getByteMinus1(data[70]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case SensorIds::CONF_XTOP0:
new_state = PanasonicDecode::getWordMinus1(data, 14);
if (this->has_state() && this->get_state() == new_state) return;
break;
case SensorIds::CONF_XTOP1:
new_state = PanasonicDecode::getWordMinus1(data, 16);
if (this->has_state() && this->get_state() == new_state) return;
break;
case SensorIds::CONF_XTOP2:
new_state = PanasonicDecode::getWordMinus1(data, 18);
if (this->has_state() && this->get_state() == new_state) return;
break;
case SensorIds::CONF_XTOP3:
new_state = PanasonicDecode::getWordMinus1(data, 20);
if (this->has_state() && this->get_state() == new_state) return;
break;
case SensorIds::CONF_XTOP4:
new_state = PanasonicDecode::getWordMinus1(data, 22);
if (this->has_state() && this->get_state() == new_state) return;
break;
case SensorIds::CONF_XTOP5:
new_state = PanasonicDecode::getWordMinus1(data, 24);
if (this->has_state() && this->get_state() == new_state) return;
break;
default: return;
};

View File

@ -106,6 +106,13 @@ namespace esphome
CONF_TOP136,
CONF_TOP137,
CONF_TOP138,
CONF_XTOP0,
CONF_XTOP1,
CONF_XTOP2,
CONF_XTOP3,
CONF_XTOP4,
CONF_XTOP5,
};
class PanasonicHeatpumpSensor : public sensor::Sensor, public Component,

View File

@ -20,72 +20,47 @@ namespace esphome
switch (this->id_)
{
case SwitchIds::CONF_SET1:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1(value), 4);
break;
}
case SwitchIds::CONF_SET10:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply64(value), 4);
break;
}
case SwitchIds::CONF_SET12:
{
this->parent_->set_command_byte(PanasonicCommand::setMultiply2(value), 8);
break;
}
case SwitchIds::CONF_SET13:
{
this->parent_->set_command_byte(PanasonicCommand::setMultiply4(value), 8);
break;
}
case SwitchIds::CONF_SET14:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 4);
break;
}
case SwitchIds::CONF_SET24:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply64(value), 5);
break;
}
case SwitchIds::CONF_SET25:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 20);
break;
}
case SwitchIds::CONF_SET28:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply4(value), 24);
break;
}
case SwitchIds::CONF_SET30:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1(value), 23);
break;
}
case SwitchIds::CONF_SET31:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 23);
break;
}
case SwitchIds::CONF_SET32:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply64(value), 23);
break;
}
case SwitchIds::CONF_SET33:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1Multiply4(value), 23);
break;
}
case SwitchIds::CONF_SET34:
{
this->parent_->set_command_byte(PanasonicCommand::setPlus1(value), 26);
break;
}
default: return;
};
this->publish_state(state);
this->keep_state_ = 2;
}
@ -103,77 +78,53 @@ namespace esphome
switch (this->id_)
{
case SwitchIds::CONF_SET1:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[4]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET10:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[4]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET24:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[5]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET12:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[111]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET13:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[117]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET28:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[24]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET25:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(data[20]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET30:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[23]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET33:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(data[23]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET31:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(data[23]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET32:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(data[23]));
if (this->state == new_state) return;
break;
}
case SwitchIds::CONF_SET34:
{
new_state = PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(data[26]));
if (this->state == new_state) return;
break;
}
default: return;
};

View File

@ -21,131 +21,89 @@ namespace esphome
switch (this->id_)
{
case TextSensorIds::CONF_TOP4:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::OperationMode, PanasonicDecode::getOperationMode(data[6]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP17:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::PowerfulMode, PanasonicDecode::getBit6and7and8(data[7]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP18:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::QuietMode, PanasonicDecode::getBit3and4and5(data[7]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP19:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::HolidayState, PanasonicDecode::getBit3and4(data[5]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP20:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ThreeWayValve, PanasonicDecode::getBit7and8(data[111]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP44:
{
new_state = PanasonicDecode::getErrorInfo(data[113], data[114]);
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP58:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::BlockedFree, PanasonicDecode::getBit5and6(data[9]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP59:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::BlockedFree, PanasonicDecode::getBit7and8(data[9]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP76:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::WaterTempControl, PanasonicDecode::getBit7and8(data[28]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP81:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::WaterTempControl, PanasonicDecode::getBit5and6(data[28]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP92:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ModelNames, PanasonicDecode::getModel(data, 129));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP94:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ZoneState, PanasonicDecode::getBit1and2(data[6]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP101:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::SolarMode, PanasonicDecode::getBit3and4(data[24]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP106:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::PumpFlowRateMode, PanasonicDecode::getBit3and4(data[29]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP107:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::LiquidType, PanasonicDecode::getBit1(data[20]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP111:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ZoneSensorType, PanasonicDecode::getLowNibbleMinus1(data[22]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP112:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ZoneSensorType, PanasonicDecode::getHighNibbleMinus1(data[22]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP114:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ExtPadHeaterType, PanasonicDecode::getBit3and4(data[25]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP125:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::TwoWayValve, PanasonicDecode::getBit5and6(data[116]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP126:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::ThreeWayValve, PanasonicDecode::getBit7and8(data[116]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
case TextSensorIds::CONF_TOP130:
{
new_state = PanasonicDecode::getTextState(PanasonicDecode::BivalentMode, PanasonicDecode::getBit5and6(data[26]));
if (this->has_state() && this->get_state() == new_state) return;
break;
}
default: return;
};