mirror of
https://github.com/ElVit/esphome_components.git
synced 2026-10-18 13:07:28 +02:00
Merge pull request #2 from ElVit/panasonic_dev
This commit is contained in:
@@ -546,6 +546,10 @@ select:
|
||||
name: "Set Bivalent Mode"
|
||||
```
|
||||
|
||||
## Known Issues
|
||||
|
||||
When the ESP controller is connected initially to the heatpump, the heatpump may not respond to any request messages. If the CZ-TAW1 is also connected to the ESP controller you will probably see some requests like 31 05 10 01 ... These are initial request messages. If the heatpump is not responding, it may help to turn off and on the power of the heatpump (switching the heatpump off is not enough). After a power on the heatpump should respond to the requests.
|
||||
|
||||
## Sources
|
||||
|
||||
:heart: A big THANKS to [Egyras](https://github.com/Egyras) and the work done on the repository [HeishaMon](https://github.com/Egyras/HeishaMon) for decoding the panasonic uart protocol and providing information to build hardware based on an ESP Chip.
|
||||
|
||||
@@ -61,87 +61,87 @@ PanasonicHeatpumpBinarySensor = panasonic_heatpump_ns.class_("PanasonicHeatpumpB
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent),
|
||||
cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent),
|
||||
|
||||
cv.Optional(CONF_TOP0): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP2): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP3): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP13): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP26): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP60): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP61): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP68): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP69): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP99): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP100): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP108): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP109): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP110): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP119): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP120): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP121): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP122): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP123): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP124): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP129): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP132): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP133): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP0): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP2): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP3): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP13): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP26): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP60): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP61): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP68): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP69): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP99): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP100): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP108): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP109): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
device_class = DEVICE_CLASS_RUNNING,
|
||||
),
|
||||
cv.Optional(CONF_TOP110): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP119): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP120): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP121): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP122): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP123): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP124): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP129): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP132): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP133): binary_sensor.binary_sensor_schema(
|
||||
PanasonicHeatpumpBinarySensor,
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace esphome
|
||||
{
|
||||
namespace panasonic_heatpump
|
||||
{
|
||||
class PanasonicHeatpumpComponent;
|
||||
class PanasonicHeatpumpBinarySensor : public binary_sensor::BinarySensor, public Component, public Parented<PanasonicHeatpumpComponent>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -89,15 +89,19 @@ namespace esphome
|
||||
{
|
||||
switch (input)
|
||||
{
|
||||
case 0: return 18;
|
||||
case 1: return 19;
|
||||
case 2: return 24;
|
||||
case 3: return 33;
|
||||
case 4: return 34;
|
||||
case 5: return 35;
|
||||
case 6: return 40;
|
||||
case 0: return 18; // heat-only
|
||||
case 1: return 19; // cool-only
|
||||
case 2: return 24; // auto
|
||||
case 3: return 25; // auto-heat
|
||||
case 4: return 26; // auto-cool
|
||||
case 5: return 33; // dhw-only
|
||||
case 6: return 34; // heat+dhw
|
||||
case 7: return 35; // cool+dhw
|
||||
case 8: return 40; // auto-dhw
|
||||
case 9: return 41; // auto-heat+dhw
|
||||
case 10: return 42; // auto-cool+dhw
|
||||
default: return 0; // do nothing
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//start of optional pcb commands
|
||||
@@ -142,8 +146,8 @@ namespace esphome
|
||||
case 2: return 0x85;
|
||||
case 3: return 0x52;
|
||||
case 4: return 0x2B;
|
||||
default: return 0; // do nothing
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
@@ -183,30 +183,18 @@ namespace esphome
|
||||
{
|
||||
switch ((int)(input & 0b111111))
|
||||
{
|
||||
case 18: // heat-only
|
||||
return 0;
|
||||
case 19: // cool-only
|
||||
return 1;
|
||||
case 24: // auto
|
||||
return 2;
|
||||
case 25: // auto-heat
|
||||
return 3;
|
||||
case 26: // auto-cool
|
||||
return 4;
|
||||
case 33: // dhw-only
|
||||
return 5;
|
||||
case 34: // heat+dhw
|
||||
return 6;
|
||||
case 35: // cool+dhw
|
||||
return 7;
|
||||
case 40: // auto-dhw
|
||||
return 8;
|
||||
case 41: // auto-heat+dhw
|
||||
return 9;
|
||||
case 42: // auto-cool+dhw
|
||||
return 10;
|
||||
default: // unknown
|
||||
return -1;
|
||||
case 18: return 0; // heat-only
|
||||
case 19: return 1; // cool-only
|
||||
case 24: return 2; // auto
|
||||
case 25: return 3; // auto-heat
|
||||
case 26: return 4; // auto-cool
|
||||
case 33: return 5; // dhw-only
|
||||
case 34: return 6; // heat+dhw
|
||||
case 35: return 7; // cool+dhw
|
||||
case 40: return 8; // auto-dhw
|
||||
case 41: return 9; // auto-heat+dhw
|
||||
case 42: return 10; // auto-cool+dhw
|
||||
default: return -1; // unknown
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,12 @@ async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID])
|
||||
for index, key in enumerate(TYPES):
|
||||
if child_config := config.get(key):
|
||||
var = await number.new_number(child_config, min_value=CONF_NUMBERS[index][0], max_value=CONF_NUMBERS[index][1], step=CONF_NUMBERS[index][2])
|
||||
var = await number.new_number(
|
||||
child_config,
|
||||
min_value=CONF_NUMBERS[index][0],
|
||||
max_value=CONF_NUMBERS[index][1],
|
||||
step=CONF_NUMBERS[index][2]
|
||||
)
|
||||
await cg.register_component(var, child_config)
|
||||
await cg.register_parented(var, config[CONF_PANASONIC_HEATPUMP_ID])
|
||||
cg.add(getattr(hub, f"set_{key}_number")(var))
|
||||
|
||||
@@ -11,12 +11,13 @@ namespace esphome
|
||||
void PanasonicHeatpumpNumber::dump_config()
|
||||
{
|
||||
LOG_NUMBER("", "Panasonic Heatpump Number", this);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpNumber::control(float value)
|
||||
{
|
||||
this->publish_state(value);
|
||||
this->parent_->number_control(this, value);
|
||||
this->parent_->control_number(this, value);
|
||||
}
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace esphome
|
||||
void PanasonicHeatpumpComponent::dump_config()
|
||||
{
|
||||
ESP_LOGCONFIG(TAG, "Panasonic Heatpump");
|
||||
delay(10);
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::setup()
|
||||
@@ -30,8 +31,6 @@ namespace esphome
|
||||
|
||||
void PanasonicHeatpumpComponent::loop()
|
||||
{
|
||||
// ToDo: if response timeout then send init again
|
||||
|
||||
this->read_response();
|
||||
this->send_request();
|
||||
this->read_request();
|
||||
@@ -46,14 +45,15 @@ namespace esphome
|
||||
uint8_t byte;
|
||||
while (this->available())
|
||||
{
|
||||
// Read byte from heatpump and forward it directly to the client (CZ-TAW1)
|
||||
this->read_byte(&byte);
|
||||
if (this->uart_client_ != nullptr)
|
||||
this->uart_client_->write_byte(byte);
|
||||
|
||||
// Message shall start with 0x71, if not skip this byte
|
||||
// Message shall start with 0x31, 0x71 or 0xF1, if not skip this byte
|
||||
if (!this->response_receiving_)
|
||||
{
|
||||
if (byte != 0x71)
|
||||
if (byte != 0x31 && byte != 0x71 && byte != 0xF1)
|
||||
continue;
|
||||
this->response_receiving_ = true;
|
||||
}
|
||||
@@ -64,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;
|
||||
@@ -78,7 +78,7 @@ namespace esphome
|
||||
// Check if message is complete
|
||||
if (this->response_message_.size() > 2 && this->response_message_.size() == this->response_payload_length_ + 3)
|
||||
{
|
||||
this->log_uart_hex("<<<", this->response_message_, ',');
|
||||
this->log_uart_hex(UART_LOG_RX, this->response_message_, ',');
|
||||
this->decode_response(this->response_message_);
|
||||
this->response_message_.clear();
|
||||
this->response_receiving_ = false;
|
||||
@@ -92,7 +92,7 @@ namespace esphome
|
||||
|
||||
if (this->next_request_ == 2) // command
|
||||
{
|
||||
this->log_uart_hex(">>>", this->command_message_, ',');
|
||||
this->log_uart_hex(UART_LOG_TX, this->command_message_, ',');
|
||||
this->write_array(this->command_message_);
|
||||
this->flush();
|
||||
return;
|
||||
@@ -103,13 +103,13 @@ namespace esphome
|
||||
if (this->next_request_ == 0) // initial
|
||||
{
|
||||
// Probably not necessary but CZ-TAW1 sends this query on boot
|
||||
this->log_uart_hex(">>>", PanasonicCommand::InitialMessage, REQUEST_INIT_MSG_SIZE, ',');
|
||||
this->log_uart_hex(UART_LOG_TX, PanasonicCommand::InitialMessage, REQUEST_INIT_MSG_SIZE, ',');
|
||||
this->write_array(PanasonicCommand::InitialMessage, REQUEST_INIT_MSG_SIZE);
|
||||
this->flush();
|
||||
}
|
||||
else if (this->next_request_ == 1) // polling
|
||||
{
|
||||
this->log_uart_hex(">>>", PanasonicCommand::PollingMessage, REQUEST_DATA_MSG_SIZE, ',');
|
||||
this->log_uart_hex(UART_LOG_TX, PanasonicCommand::PollingMessage, REQUEST_DATA_MSG_SIZE, ',');
|
||||
this->write_array(PanasonicCommand::PollingMessage, REQUEST_DATA_MSG_SIZE);
|
||||
this->flush();
|
||||
}
|
||||
@@ -122,13 +122,14 @@ namespace esphome
|
||||
uint8_t byte;
|
||||
while (this->uart_client_->available())
|
||||
{
|
||||
// Read byte from client and forward it directly to the heatpump
|
||||
this->uart_client_->read_byte(&byte);
|
||||
this->write_byte(byte);
|
||||
|
||||
// Message shall start with 0x71, if not skip this byte
|
||||
// Message shall start with 0x31, 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;
|
||||
@@ -154,20 +155,40 @@ namespace esphome
|
||||
// Check if message is complete
|
||||
if (this->request_message_.size() > 2 && this->request_message_.size() == this->request_payload_length_ + 3)
|
||||
{
|
||||
this->log_uart_hex(">>>", this->request_message_, ',');
|
||||
this->log_uart_hex(UART_LOG_TX, this->request_message_, ',');
|
||||
this->request_message_.clear();
|
||||
this->request_receiving_ = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::log_uart_hex(std::string prefix, const uint8_t *data, size_t length, uint8_t separator)
|
||||
void PanasonicHeatpumpComponent::log_uart_hex(UartLogDirection direction, const uint8_t *data, size_t length, uint8_t separator)
|
||||
{
|
||||
if (this->log_uart_msg_ == false) return;
|
||||
|
||||
std::string logStr;
|
||||
std::string msgDir = direction == UART_LOG_TX ? ">>>" : "<<<";
|
||||
std::string msgType = "response";
|
||||
if (direction == UART_LOG_TX)
|
||||
{
|
||||
switch(data[0])
|
||||
{
|
||||
case 0x31:
|
||||
msgType = "initial_request";
|
||||
break;
|
||||
case 0x71:
|
||||
msgType = "polling_request";
|
||||
break;
|
||||
case 0xF1:
|
||||
msgType = "command_request";
|
||||
break;
|
||||
default:
|
||||
msgType = "request";
|
||||
};
|
||||
}
|
||||
|
||||
logStr = "[" + std::to_string(length) + "]";
|
||||
ESP_LOGI(TAG, "%s %s", prefix.c_str(), logStr.c_str());
|
||||
ESP_LOGI(TAG, "%s %s%s", msgDir.c_str(), msgType.c_str(), logStr.c_str());
|
||||
delay(10);
|
||||
|
||||
logStr = "";
|
||||
@@ -182,7 +203,7 @@ namespace esphome
|
||||
size_t chunkSize = 90;
|
||||
for (size_t i = 0; i < logStr.length(); i += chunkSize)
|
||||
{
|
||||
ESP_LOGI(TAG, "%s %s", prefix.c_str(), logStr.substr(i, chunkSize).c_str());
|
||||
ESP_LOGD(TAG, "%s %s", msgDir.c_str(), logStr.substr(i, chunkSize).c_str());
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
@@ -214,6 +235,35 @@ namespace esphome
|
||||
return;
|
||||
}
|
||||
|
||||
this->publish_sensor(bytes);
|
||||
this->publish_binary_sensor(bytes);
|
||||
this->publish_text_sensor(bytes);
|
||||
this->publish_number(bytes);
|
||||
this->publish_select(bytes);
|
||||
this->publish_switch(bytes);
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::set_command_byte(uint8_t value, uint8_t index)
|
||||
{
|
||||
if (this->next_request_ == 1)
|
||||
{
|
||||
// initialize the command
|
||||
command_message_.clear();
|
||||
command_message_.insert(this->command_message_.end(), PanasonicCommand::CommandMessage,
|
||||
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);
|
||||
|
||||
// command will be send on next loop
|
||||
this->next_request_ = 2;
|
||||
this->trigger_request_ = true;
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::publish_sensor(std::vector<uint8_t> bytes)
|
||||
{
|
||||
#ifdef USE_SENSOR
|
||||
if (this->top1_sensor_) this->top1_sensor_->publish_state(PanasonicDecode::getPumpFlow(bytes[169], bytes[170]));
|
||||
if (this->top5_sensor_) this->top5_sensor_->publish_state(PanasonicDecode::getByteMinus128(bytes[143]) + PanasonicDecode::getFractional(bytes[118], 0));
|
||||
@@ -311,6 +361,10 @@ namespace esphome
|
||||
if (this->top137_sensor_) this->top137_sensor_->publish_state(PanasonicDecode::getByteMinus1(bytes[69]));
|
||||
if (this->top138_sensor_) this->top138_sensor_->publish_state(PanasonicDecode::getByteMinus1(bytes[70]));
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::publish_binary_sensor(std::vector<uint8_t> bytes)
|
||||
{
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
if (this->top0_binary_sensor_) this->top0_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[4])));
|
||||
if (this->top2_binary_sensor_) this->top2_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[4])));
|
||||
@@ -336,6 +390,10 @@ namespace esphome
|
||||
if (this->top132_binary_sensor_) this->top132_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(bytes[26])));
|
||||
if (this->top133_binary_sensor_) this->top133_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[26])));
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::publish_text_sensor(std::vector<uint8_t> bytes)
|
||||
{
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
if (this->top4_text_sensor_) this->top4_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::OpModeDesc, PanasonicDecode::getOpMode(bytes[6])));
|
||||
if (this->top17_text_sensor_) this->top17_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Powerfulmode, PanasonicDecode::getBit6and7and8(bytes[7])));
|
||||
@@ -359,6 +417,10 @@ namespace esphome
|
||||
if (this->top126_text_sensor_) this->top126_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Valve, PanasonicDecode::getBit7and8(bytes[116])));
|
||||
if (this->top130_text_sensor_) this->top130_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Bivalent, PanasonicDecode::getBit5and6(bytes[26])));
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::publish_number(std::vector<uint8_t> bytes)
|
||||
{
|
||||
#ifdef USE_NUMBER
|
||||
if (this->set11_number_) this->set11_number_->publish_state(PanasonicDecode::getByteMinus128(bytes[42]));
|
||||
if (this->set20_number_) this->set20_number_->publish_state(PanasonicDecode::getByteMinus128(bytes[99]));
|
||||
@@ -394,6 +456,10 @@ namespace esphome
|
||||
if (this->set37_number_) this->set37_number_->publish_state(PanasonicDecode::getByteMinus128(bytes[66]));
|
||||
if (this->set38_number_) this->set38_number_->publish_state(PanasonicDecode::getByteMinus128(bytes[68]));
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::publish_select(std::vector<uint8_t> bytes)
|
||||
{
|
||||
#ifdef USE_SELECT
|
||||
if (this->set9_select_) this->set9_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::OpModeDesc, PanasonicDecode::getOpMode(bytes[6])));
|
||||
if (this->set4_select_) this->set4_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Powerfulmode, PanasonicDecode::getBit6and7and8(bytes[7])));
|
||||
@@ -403,6 +469,10 @@ namespace esphome
|
||||
if (this->set26_select_) this->set26_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::ExtPadHeaterType, PanasonicDecode::getBit3and4(bytes[25])));
|
||||
if (this->set35_select_) this->set35_select_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::Bivalent, PanasonicDecode::getBit5and6(bytes[26])));
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::publish_switch(std::vector<uint8_t> bytes)
|
||||
{
|
||||
#ifdef USE_SWITCH
|
||||
if (this->set1_switch_) this->set1_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[4])));
|
||||
if (this->set10_switch_) this->set10_switch_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[4])));
|
||||
@@ -418,91 +488,75 @@ namespace esphome
|
||||
#endif
|
||||
}
|
||||
|
||||
void PanasonicHeatpumpComponent::set_command_message(uint8_t value, uint8_t index)
|
||||
{
|
||||
if (this->next_request_ == 1)
|
||||
{
|
||||
// initialize the command
|
||||
command_message_.clear();
|
||||
command_message_.insert(this->command_message_.end(), PanasonicCommand::CommandMessage,
|
||||
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);
|
||||
|
||||
// command will be send on next loop
|
||||
this->next_request_ = 2;
|
||||
this->trigger_request_ = true;
|
||||
}
|
||||
|
||||
#ifdef USE_NUMBER
|
||||
void PanasonicHeatpumpComponent::number_control(number::Number* object, float value)
|
||||
void PanasonicHeatpumpComponent::control_number(number::Number* object, float value)
|
||||
{
|
||||
if (object == this->set5_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 38);
|
||||
else if (object == this->set6_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 39);
|
||||
else if (object == this->set7_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 40);
|
||||
else if (object == this->set8_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 41);
|
||||
else if (object == this->set11_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 42);
|
||||
else if (object == this->set15_number_) this->set_command_message(PanasonicCommand::setPlus1(value), 45);
|
||||
else if (object == this->set16_1_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 75);
|
||||
else if (object == this->set16_2_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 76);
|
||||
else if (object == this->set16_3_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 77);
|
||||
else if (object == this->set16_4_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 78);
|
||||
else if (object == this->set16_5_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 79);
|
||||
else if (object == this->set16_6_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 80);
|
||||
else if (object == this->set16_7_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 81);
|
||||
else if (object == this->set16_8_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 82);
|
||||
else if (object == this->set16_9_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 86);
|
||||
else if (object == this->set16_10_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 87);
|
||||
else if (object == this->set16_11_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 88);
|
||||
else if (object == this->set16_12_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 89);
|
||||
else if (object == this->set16_13_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 90);
|
||||
else if (object == this->set16_14_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 91);
|
||||
else if (object == this->set16_15_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 92);
|
||||
else if (object == this->set16_16_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 93);
|
||||
else if (object == this->set18_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 84);
|
||||
else if (object == this->set19_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 94);
|
||||
else if (object == this->set20_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 99);
|
||||
else if (object == this->set21_number_) this->set_command_message(PanasonicCommand::setPlus1(value), 104);
|
||||
else if (object == this->set22_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 105);
|
||||
else if (object == this->set23_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 106);
|
||||
else if (object == this->set27_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 59);
|
||||
else if (object == this->set29_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 83);
|
||||
else if (object == this->set36_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 65);
|
||||
else if (object == this->set37_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 66);
|
||||
else if (object == this->set38_number_) this->set_command_message(PanasonicCommand::setPlus128(value), 68);
|
||||
if (object == this->set5_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 38);
|
||||
else if (object == this->set6_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 39);
|
||||
else if (object == this->set7_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 40);
|
||||
else if (object == this->set8_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 41);
|
||||
else if (object == this->set11_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 42);
|
||||
else if (object == this->set15_number_) this->set_command_byte(PanasonicCommand::setPlus1(value), 45);
|
||||
else if (object == this->set16_1_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 75);
|
||||
else if (object == this->set16_2_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 76);
|
||||
else if (object == this->set16_3_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 77);
|
||||
else if (object == this->set16_4_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 78);
|
||||
else if (object == this->set16_5_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 79);
|
||||
else if (object == this->set16_6_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 80);
|
||||
else if (object == this->set16_7_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 81);
|
||||
else if (object == this->set16_8_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 82);
|
||||
else if (object == this->set16_9_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 86);
|
||||
else if (object == this->set16_10_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 87);
|
||||
else if (object == this->set16_11_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 88);
|
||||
else if (object == this->set16_12_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 89);
|
||||
else if (object == this->set16_13_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 90);
|
||||
else if (object == this->set16_14_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 91);
|
||||
else if (object == this->set16_15_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 92);
|
||||
else if (object == this->set16_16_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 93);
|
||||
else if (object == this->set18_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 84);
|
||||
else if (object == this->set19_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 94);
|
||||
else if (object == this->set20_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 99);
|
||||
else if (object == this->set21_number_) this->set_command_byte(PanasonicCommand::setPlus1(value), 104);
|
||||
else if (object == this->set22_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 105);
|
||||
else if (object == this->set23_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 106);
|
||||
else if (object == this->set27_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 59);
|
||||
else if (object == this->set29_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 83);
|
||||
else if (object == this->set36_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 65);
|
||||
else if (object == this->set37_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 66);
|
||||
else if (object == this->set38_number_) this->set_command_byte(PanasonicCommand::setPlus128(value), 68);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SELECT
|
||||
void PanasonicHeatpumpComponent::select_control(select::Select* object, size_t value)
|
||||
void PanasonicHeatpumpComponent::control_select(select::Select* object, size_t value)
|
||||
{
|
||||
if (object == this->set2_select_) this->set_command_message(PanasonicCommand::setPlus1Multiply16(value), 5);
|
||||
else if (object == this->set3_select_) this->set_command_message(PanasonicCommand::setPlus1Multiply8(value), 7);
|
||||
else if (object == this->set4_select_) this->set_command_message(PanasonicCommand::setPlus73(value), 7);
|
||||
else if (object == this->set9_select_) this->set_command_message(PanasonicCommand::setOperationMode(value), 6);
|
||||
else if (object == this->set17_select_) this->set_command_message(PanasonicCommand::setPlus1Multiply64(value), 6);
|
||||
else if (object == this->set26_select_) this->set_command_message(PanasonicCommand::setPlus1Multiply16(value), 25);
|
||||
else if (object == this->set35_select_) this->set_command_message(PanasonicCommand::setPlus1Multiply4(value), 26);
|
||||
if (object == this->set2_select_) this->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 5);
|
||||
else if (object == this->set3_select_) this->set_command_byte(PanasonicCommand::setPlus1Multiply8(value), 7);
|
||||
else if (object == this->set4_select_) this->set_command_byte(PanasonicCommand::setPlus73(value), 7);
|
||||
else if (object == this->set9_select_) this->set_command_byte(PanasonicCommand::setOperationMode(value), 6);
|
||||
else if (object == this->set17_select_) this->set_command_byte(PanasonicCommand::setPlus1Multiply64(value), 6);
|
||||
else if (object == this->set26_select_) this->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 25);
|
||||
else if (object == this->set35_select_) this->set_command_byte(PanasonicCommand::setPlus1Multiply4(value), 26);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SWITCH
|
||||
void PanasonicHeatpumpComponent::switch_control(switch_::Switch* object, size_t value)
|
||||
void PanasonicHeatpumpComponent::control_switch(switch_::Switch* object, size_t value)
|
||||
{
|
||||
if (object == this->set1_switch_) this->set_command_message(PanasonicCommand::setPlus1(value), 4);
|
||||
else if (object == this->set10_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply64(value), 4);
|
||||
else if (object == this->set12_switch_) this->set_command_message(PanasonicCommand::setMultiply2(value), 8);
|
||||
else if (object == this->set13_switch_) this->set_command_message(PanasonicCommand::setMultiply4(value), 8);
|
||||
else if (object == this->set14_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply16(value), 4);
|
||||
else if (object == this->set24_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply64(value), 5);
|
||||
else if (object == this->set25_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply16(value), 20);
|
||||
else if (object == this->set28_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply4(value), 24);
|
||||
else if (object == this->set30_switch_) this->set_command_message(PanasonicCommand::setPlus1(value), 23);
|
||||
else if (object == this->set31_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply16(value), 23);
|
||||
else if (object == this->set32_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply64(value), 23);
|
||||
else if (object == this->set33_switch_) this->set_command_message(PanasonicCommand::setPlus1Multiply4(value), 23);
|
||||
else if (object == this->set34_switch_) this->set_command_message(PanasonicCommand::setPlus1(value), 26);
|
||||
if (object == this->set1_switch_) this->set_command_byte(PanasonicCommand::setPlus1(value), 4);
|
||||
else if (object == this->set10_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply64(value), 4);
|
||||
else if (object == this->set12_switch_) this->set_command_byte(PanasonicCommand::setMultiply2(value), 8);
|
||||
else if (object == this->set13_switch_) this->set_command_byte(PanasonicCommand::setMultiply4(value), 8);
|
||||
else if (object == this->set14_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 4);
|
||||
else if (object == this->set24_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply64(value), 5);
|
||||
else if (object == this->set25_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 20);
|
||||
else if (object == this->set28_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply4(value), 24);
|
||||
else if (object == this->set30_switch_) this->set_command_byte(PanasonicCommand::setPlus1(value), 23);
|
||||
else if (object == this->set31_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply16(value), 23);
|
||||
else if (object == this->set32_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply64(value), 23);
|
||||
else if (object == this->set33_switch_) this->set_command_byte(PanasonicCommand::setPlus1Multiply4(value), 23);
|
||||
else if (object == this->set34_switch_) this->set_command_byte(PanasonicCommand::setPlus1(value), 26);
|
||||
}
|
||||
#endif
|
||||
} // namespace panasonic_heatpump
|
||||
|
||||
@@ -32,6 +32,12 @@ namespace esphome
|
||||
{
|
||||
namespace panasonic_heatpump
|
||||
{
|
||||
enum UartLogDirection
|
||||
{
|
||||
UART_LOG_RX,
|
||||
UART_LOG_TX,
|
||||
};
|
||||
|
||||
class PanasonicHeatpumpComponent : public PollingComponent, public uart::UARTDevice
|
||||
{
|
||||
public:
|
||||
@@ -216,7 +222,7 @@ namespace esphome
|
||||
SUB_NUMBER(set37);
|
||||
SUB_NUMBER(set38);
|
||||
|
||||
void number_control(number::Number* object, float value);
|
||||
void control_number(number::Number* object, float value);
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
SUB_SELECT(set2);
|
||||
@@ -227,7 +233,7 @@ namespace esphome
|
||||
SUB_SELECT(set26);
|
||||
SUB_SELECT(set35);
|
||||
|
||||
void select_control(select::Select* object, size_t value);
|
||||
void control_select(select::Select* object, size_t value);
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
SUB_SWITCH(set1);
|
||||
@@ -244,7 +250,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;
|
||||
@@ -254,15 +260,11 @@ namespace esphome
|
||||
void update() override;
|
||||
void loop() override;
|
||||
|
||||
//void set_uart_hp(uart::UARTComponent *uart) { this->uart_hp_ = uart; }
|
||||
//void set_uart_wm(uart::UARTComponent *uart) { this->uart_wm_ = uart; }
|
||||
void set_uart_client(uart::UARTComponent *uart) { this->uart_client_ = uart; }
|
||||
void set_log_uart_msg(bool enable) { this->log_uart_msg_ = enable; }
|
||||
void set_polling_time(uint32_t time_sec) { this->polling_time_ = time_sec; }
|
||||
|
||||
protected:
|
||||
//uart::UARTComponent* uart_hp_;
|
||||
//uart::UARTComponent* uart_wm_;
|
||||
uart::UARTComponent* uart_client_{nullptr};
|
||||
bool log_uart_msg_{false};
|
||||
uint32_t polling_time_{1};
|
||||
@@ -281,9 +283,18 @@ namespace esphome
|
||||
void send_request();
|
||||
void read_request();
|
||||
void decode_response(std::vector<uint8_t> data);
|
||||
void set_command_message(uint8_t value, uint8_t index);
|
||||
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);
|
||||
void set_command_byte(uint8_t value, uint8_t index);
|
||||
void publish_sensor(std::vector<uint8_t> bytes);
|
||||
void publish_binary_sensor(std::vector<uint8_t> bytes);
|
||||
void publish_text_sensor(std::vector<uint8_t> bytes);
|
||||
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(UartLogDirection direction, const std::vector<uint8_t> &data, uint8_t separator)
|
||||
{
|
||||
this->log_uart_hex(direction, &data[0], data.size(), separator);
|
||||
}
|
||||
void log_uart_hex(UartLogDirection direction, const uint8_t *data, size_t length, uint8_t separator);
|
||||
};
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
|
||||
@@ -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)
|
||||
@@ -18,7 +19,7 @@ namespace esphome
|
||||
this->publish_state(value);
|
||||
auto index = this->active_index();
|
||||
if (index.has_value())
|
||||
this->parent_->select_control(this, index.value());
|
||||
this->parent_->control_select(this, index.value());
|
||||
}
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@ namespace esphome
|
||||
void PanasonicHeatpumpSensor::dump_config()
|
||||
{
|
||||
LOG_SENSOR("", "Panasonic Heatpump Sensor", this);
|
||||
delay(10);
|
||||
}
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace esphome
|
||||
{
|
||||
namespace panasonic_heatpump
|
||||
{
|
||||
class PanasonicHeatpumpComponent;
|
||||
class PanasonicHeatpumpSensor : public sensor::Sensor, public Component, public Parented<PanasonicHeatpumpComponent>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -11,13 +11,14 @@ namespace esphome
|
||||
void PanasonicHeatpumpSwitch::dump_config()
|
||||
{
|
||||
LOG_SWITCH("", "Panasonic Heatpump Switch", this);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
|
||||
void PanasonicHeatpumpSwitch::write_state(bool state)
|
||||
{
|
||||
this->publish_state(state);
|
||||
size_t value = state ? 1 : 0;
|
||||
this->parent_->switch_control(this, value);
|
||||
this->parent_->control_switch(this, value);
|
||||
}
|
||||
} // namespace panasonic_heatpump
|
||||
} // namespace esphome
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace esphome
|
||||
{
|
||||
namespace panasonic_heatpump
|
||||
{
|
||||
class PanasonicHeatpumpComponent;
|
||||
class PanasonicHeatpumpSwitch : public switch_::Switch, public Component, public Parented<PanasonicHeatpumpComponent>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -74,88 +74,88 @@ PanasonicHeatpumpTextSensor = panasonic_heatpump_ns.class_("PanasonicHeatpumpTex
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent),
|
||||
cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent),
|
||||
|
||||
cv.Optional(CONF_TOP4): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_OPERATING_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP17): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_POWERFUL_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP18): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_QUIET_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP19): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_HOLIDAY_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP20): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_VALVE,
|
||||
),
|
||||
cv.Optional(CONF_TOP44): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_ERROR,
|
||||
),
|
||||
cv.Optional(CONF_TOP58): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_BLOCKED,
|
||||
),
|
||||
cv.Optional(CONF_TOP59): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_BLOCKED,
|
||||
),
|
||||
cv.Optional(CONF_TOP76): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_HEATING_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP81): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_COOLING_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP92): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_MODEL,
|
||||
),
|
||||
cv.Optional(CONF_TOP94): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_ZONE,
|
||||
),
|
||||
cv.Optional(CONF_TOP101): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_SOLAR_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP106): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_PUMP,
|
||||
),
|
||||
cv.Optional(CONF_TOP107): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_LIQUID,
|
||||
),
|
||||
cv.Optional(CONF_TOP111): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP112): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP114): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_EXTERNAL_PAD_HEATER,
|
||||
),
|
||||
cv.Optional(CONF_TOP125): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_VALVE,
|
||||
),
|
||||
cv.Optional(CONF_TOP126): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_VALVE,
|
||||
),
|
||||
cv.Optional(CONF_TOP130): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,),
|
||||
cv.Optional(CONF_TOP4): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_OPERATING_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP17): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_POWERFUL_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP18): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_QUIET_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP19): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_HOLIDAY_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP20): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_VALVE,
|
||||
),
|
||||
cv.Optional(CONF_TOP44): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_ERROR,
|
||||
),
|
||||
cv.Optional(CONF_TOP58): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_BLOCKED,
|
||||
),
|
||||
cv.Optional(CONF_TOP59): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_BLOCKED,
|
||||
),
|
||||
cv.Optional(CONF_TOP76): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_HEATING_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP81): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_COOLING_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP92): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_MODEL,
|
||||
),
|
||||
cv.Optional(CONF_TOP94): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_ZONE,
|
||||
),
|
||||
cv.Optional(CONF_TOP101): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_SOLAR_MODE,
|
||||
),
|
||||
cv.Optional(CONF_TOP106): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_PUMP,
|
||||
),
|
||||
cv.Optional(CONF_TOP107): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_LIQUID,
|
||||
),
|
||||
cv.Optional(CONF_TOP111): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP112): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
),
|
||||
cv.Optional(CONF_TOP114): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_EXTERNAL_PAD_HEATER,
|
||||
),
|
||||
cv.Optional(CONF_TOP125): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_VALVE,
|
||||
),
|
||||
cv.Optional(CONF_TOP126): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,
|
||||
icon=ICON_VALVE,
|
||||
),
|
||||
cv.Optional(CONF_TOP130): text_sensor.text_sensor_schema(
|
||||
PanasonicHeatpumpTextSensor,),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace esphome
|
||||
{
|
||||
namespace panasonic_heatpump
|
||||
{
|
||||
class PanasonicHeatpumpComponent;
|
||||
class PanasonicHeatpumpTextSensor : public text_sensor::TextSensor, public Component, public Parented<PanasonicHeatpumpComponent>
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user