From bcfcfd26f5b1cf13b70a9dc2c2d2f14e6d159769 Mon Sep 17 00:00:00 2001 From: ElVit Date: Mon, 3 Feb 2025 13:05:59 +0100 Subject: [PATCH] panasonic heatpump: removed buttons, updated numbers, selects and switches --- .../panasonic_heatpump/button/__init__.py | 37 -- .../button/panasonic_heatpump_button.cpp | 13 - .../button/panasonic_heatpump_button.h | 19 - components/panasonic_heatpump/commands.cpp | 60 ++-- components/panasonic_heatpump/commands.h | 49 +-- .../panasonic_heatpump/number/__init__.py | 340 +++++++++++------- .../panasonic_heatpump/panasonic_heatpump.cpp | 220 ++++++------ .../panasonic_heatpump/panasonic_heatpump.h | 112 +++--- .../panasonic_heatpump/select/__init__.py | 62 ++-- .../select/panasonic_heatpump_select.cpp | 4 +- .../panasonic_heatpump/switch/__init__.py | 95 +++-- 11 files changed, 529 insertions(+), 482 deletions(-) delete mode 100644 components/panasonic_heatpump/button/__init__.py delete mode 100644 components/panasonic_heatpump/button/panasonic_heatpump_button.cpp delete mode 100644 components/panasonic_heatpump/button/panasonic_heatpump_button.h diff --git a/components/panasonic_heatpump/button/__init__.py b/components/panasonic_heatpump/button/__init__.py deleted file mode 100644 index f723e77..0000000 --- a/components/panasonic_heatpump/button/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import button -from esphome.const import ( - ENTITY_CATEGORY_CONFIG, -) -from .. import CONF_PANASONIC_HEATPUMP_ID, PanasonicHeatpumpComponent, panasonic_heatpump_ns - - -CONF_RESET = "reset" - -TYPES = [ - CONF_RESET, -] - -PanasonicHeatpumpButton = panasonic_heatpump_ns.class_("PanasonicHeatpumpButton", button.Button) - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent), - - cv.Optional(CONF_RESET): button.button_schema( - PanasonicHeatpumpButton, - ), - } -) - -async def to_code(config): - hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) - for key in TYPES: - await setup_conf(config, key, hub) - -async def setup_conf(parent_config, key, hub): - if child_config := parent_config.get(key): - var = await button.new_button(child_config) - await cg.register_parented(var, parent_config[CONF_PANASONIC_HEATPUMP_ID]) - cg.add(getattr(hub, f"set_{key}_button")(var)) diff --git a/components/panasonic_heatpump/button/panasonic_heatpump_button.cpp b/components/panasonic_heatpump/button/panasonic_heatpump_button.cpp deleted file mode 100644 index b3c429b..0000000 --- a/components/panasonic_heatpump/button/panasonic_heatpump_button.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "panasonic_heatpump_button.h" - - -namespace esphome -{ - namespace panasonic_heatpump - { - void PanasonicHeatpumpButton::press_action() - { - this->parent_->button_press_action(this); - } - } // namespace panasonic_heatpump -} // namespace esphome diff --git a/components/panasonic_heatpump/button/panasonic_heatpump_button.h b/components/panasonic_heatpump/button/panasonic_heatpump_button.h deleted file mode 100644 index 4f3128b..0000000 --- a/components/panasonic_heatpump/button/panasonic_heatpump_button.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "esphome/components/button/button.h" -#include "../panasonic_heatpump.h" - - -namespace esphome -{ - namespace panasonic_heatpump - { - class PanasonicHeatpumpButton : public button::Button, public Parented - { - public: - PanasonicHeatpumpButton() = default; - - protected: - void press_action() override; - }; - } // namespace panasonic_heatpump -} // namespace esphome diff --git a/components/panasonic_heatpump/commands.cpp b/components/panasonic_heatpump/commands.cpp index d6e9d49..447be26 100644 --- a/components/panasonic_heatpump/commands.cpp +++ b/components/panasonic_heatpump/commands.cpp @@ -5,6 +5,30 @@ namespace esphome { namespace panasonic_heatpump { + const uint8_t PanasonicCommand::InitialMessage[REQUEST_INITIAL_SIZE] = { + 0x31, 0x05, 0x10, 0x01, 0x00, 0x00, 0x00, 0xB9 + }; + const uint8_t PanasonicCommand::PeriodicalMessage[REQUEST_DATA_SIZE] = { + 0x71, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 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, 0x12 + }; + const uint8_t PanasonicCommand::CommandMessage[REQUEST_DATA_SIZE] = { + 0xF1, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 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, 0x92 + }; + uint8_t PanasonicCommand::calcChecksum(std::vector& data, int length) { uint8_t checksum = 0; @@ -16,52 +40,52 @@ namespace esphome return checksum; } - uint8_t PanasonicCommand::setMultiply2(unsigned int input) + uint8_t PanasonicCommand::setMultiply2(size_t input) { return input * 2; } - uint8_t PanasonicCommand::setMultiply4(unsigned int input) + uint8_t PanasonicCommand::setMultiply4(size_t input) { return input * 4; } - uint8_t PanasonicCommand::setPlus1Multiply4(unsigned int input) + uint8_t PanasonicCommand::setPlus1Multiply4(size_t input) { return (input + 1) * 4; } - uint8_t PanasonicCommand::setPlus1Multiply8(unsigned int input) + uint8_t PanasonicCommand::setPlus1Multiply8(size_t input) { return (input + 1) * 8; } - uint8_t PanasonicCommand::setPlus1Multiply16(unsigned int input) + uint8_t PanasonicCommand::setPlus1Multiply16(size_t input) { return (input + 1) * 16; } - uint8_t PanasonicCommand::setPlus1Multiply64(unsigned int input) + uint8_t PanasonicCommand::setPlus1Multiply64(size_t input) { return (input + 1) * 64; } - uint8_t PanasonicCommand::setPlus1(unsigned int input) + uint8_t PanasonicCommand::setPlus1(size_t input) { return input + 1; } - uint8_t PanasonicCommand::setPlus73(unsigned int input) + uint8_t PanasonicCommand::setPlus73(size_t input) { return input + 73; } - uint8_t PanasonicCommand::setPlus128(unsigned int input) + uint8_t PanasonicCommand::setPlus128(size_t input) { return input + 128; } - uint8_t PanasonicCommand::setOperationMode(unsigned int input) + uint8_t PanasonicCommand::setOperationMode(size_t input) { switch (input) { @@ -76,20 +100,6 @@ namespace esphome return 0; } - uint8_t PanasonicCommand::setBivalentMode(unsigned int input) - { - switch (input) - { - case 0: return 101; - case 1: return 102; - case 2: return 104; - case 3: return 105; - case 4: return 108; - case 5: return 109; - } - return 0; - } - //start of optional pcb commands uint8_t PanasonicCommand::temp2hex(float temp) @@ -123,7 +133,7 @@ namespace esphome return (byte6 & ~(base << bit)) | (val << bit); } - uint8_t PanasonicCommand::setDemandControl(unsigned int input) + uint8_t PanasonicCommand::setDemandControl(size_t input) { switch (input) { diff --git a/components/panasonic_heatpump/commands.h b/components/panasonic_heatpump/commands.h index 5b07971..fcc8ab4 100644 --- a/components/panasonic_heatpump/commands.h +++ b/components/panasonic_heatpump/commands.h @@ -17,44 +17,23 @@ namespace esphome PanasonicCommand() = delete; static uint8_t calcChecksum(std::vector& data, int length); - static uint8_t setMultiply2(unsigned int input); - static uint8_t setMultiply4(unsigned int input); - static uint8_t setPlus1Multiply4(unsigned int input); - static uint8_t setPlus1Multiply8(unsigned int input); - static uint8_t setPlus1Multiply16(unsigned int input); - static uint8_t setPlus1Multiply64(unsigned int input); - static uint8_t setPlus1(unsigned int input); - static uint8_t setPlus73(unsigned int input); - static uint8_t setPlus128(unsigned int input); - static uint8_t setOperationMode(unsigned int input); - static uint8_t setBivalentMode(unsigned int input); + static uint8_t setMultiply2(size_t input); + static uint8_t setMultiply4(size_t input); + static uint8_t setPlus1Multiply4(size_t input); + static uint8_t setPlus1Multiply8(size_t input); + static uint8_t setPlus1Multiply16(size_t input); + static uint8_t setPlus1Multiply64(size_t input); + static uint8_t setPlus1(size_t input); + static uint8_t setPlus73(size_t input); + static uint8_t setPlus128(size_t input); + static uint8_t setOperationMode(size_t input); static uint8_t temp2hex(float temp); static uint8_t setByte6(uint8_t byte6, int val, int base, int bit); - static uint8_t setDemandControl(unsigned int input); + static uint8_t setDemandControl(size_t input); - static constexpr uint8_t InitialMessage[REQUEST_INITIAL_SIZE] = { - 0x31, 0x05, 0x10, 0x01, 0x00, 0x00, 0x00, 0xB9 - }; - static constexpr uint8_t PeriodicalMessage[REQUEST_DATA_SIZE] = { - 0x71, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 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, 0x12 - }; - static constexpr uint8_t CommandMessage[REQUEST_DATA_SIZE] = { - 0xF1, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 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, 0x92 - }; + static const uint8_t InitialMessage[REQUEST_INITIAL_SIZE]; + static const uint8_t PeriodicalMessage[REQUEST_DATA_SIZE]; + static const uint8_t CommandMessage[REQUEST_DATA_SIZE]; }; } // namespace panasonic_heatpump } // namespace esphome diff --git a/components/panasonic_heatpump/number/__init__.py b/components/panasonic_heatpump/number/__init__.py index e1eca6b..10d9e44 100644 --- a/components/panasonic_heatpump/number/__init__.py +++ b/components/panasonic_heatpump/number/__init__.py @@ -2,78 +2,119 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import number from esphome.const import ( - UNIT_CENTIMETER, - UNIT_PERCENT, + UNIT_CELSIUS, + UNIT_KELVIN, + UNIT_MINUTE, + ENTITY_CATEGORY_CONFIG, ) from .. import CONF_PANASONIC_HEATPUMP_ID, PanasonicHeatpumpComponent, panasonic_heatpump_ns -CONF_SET_Z1_HEAT_REQUEST_TEMPERATURE = "z1_heat_request_temperature" -CONF_SET_Z1_COOL_REQUEST_TEMPERATURE = "z1_cool_request_temperature" -CONF_SET_Z2_HEAT_REQUEST_TEMPERATURE = "z2_heat_request_temperature" -CONF_SET_Z2_COOL_REQUEST_TEMPERATURE = "z2_cool_request_temperature" -CONF_SET_DHW_TEMP = "dhw_temp" -CONF_SET_MAX_PUMP_DUTY = "max_pump_duty" -CONF_SET_ZONE1_HEAT_TARGET_HIGH = "zone1_heat_target_high" -CONF_SET_ZONE1_HEAT_TARGET_LOW = "zone1_heat_target_low" -CONF_SET_ZONE1_HEAT_OUTSIDE_LOW = "zone1_heat_outside_low" -CONF_SET_ZONE1_HEAT_OUTSIDE_HIGH = "zone1_heat_outside_high" -CONF_SET_ZONE2_HEAT_TARGET_HIGH = "zone2_heat_target_high" -CONF_SET_ZONE2_HEAT_TARGET_LOW = "zone2_heat_target_low" -CONF_SET_ZONE2_HEAT_OUTSIDE_LOW = "zone2_heat_outside_low" -CONF_SET_ZONE2_HEAT_OUTSIDE_HIGH = "zone2_heat_outside_high" -CONF_SET_ZONE1_COOL_TARGET_HIGH = "zone1_cool_target_high" -CONF_SET_ZONE1_COOL_TARGET_LOW = "zone1_cool_target_low" -CONF_SET_ZONE1_COOL_OUTSIDE_LOW = "zone1_cool_outside_low" -CONF_SET_ZONE1_COOL_OUTSIDE_HIGH = "zone1_cool_outside_high" -CONF_SET_ZONE2_COOL_TARGET_HIGH = "zone2_cool_target_high" -CONF_SET_ZONE2_COOL_TARGET_LOW = "zone2_cool_target_low" -CONF_SET_ZONE2_COOL_OUTSIDE_LOW = "zone2_cool_outside_low" -CONF_SET_ZONE2_COOL_OUTSIDE_HIGH = "zone2_cool_outside_high" -CONF_SET_FLOOR_HEAT_DELTA = "floor_heat_delta" -CONF_SET_FLOOR_COOL_DELTA = "floor_cool_delta" -CONF_SET_DHW_HEAT_DELTA = "dhw_heat_delta" -CONF_SET_HEATER_DELAY_TIME = "heater_delay_time" -CONF_SET_HEATER_START_DELTA = "heater_start_delta" -CONF_SET_HEATER_STOP_DELTA = "heater_stop_delta" -CONF_SET_BUFFER_DELTA = "buffer_delta" -CONF_SET_HEATINGOFFOUTDOORTEMP = "heatingoffoutdoortemp" -CONF_SET_BIVALENT_START_TEMPERATURE = "bivalent_start_temperature" -CONF_SET_BIVALENT_STOP_TEMPERATURE = "bivalent_stop_temperature" +CONF_SET5 = "set5" +CONF_SET6 = "set6" +CONF_SET7 = "set7" +CONF_SET8 = "set8" +CONF_SET11 = "set11" +CONF_SET15 = "set15" +CONF_SET16_1 = "set16_1" +CONF_SET16_2 = "set16_2" +CONF_SET16_3 = "set16_3" +CONF_SET16_4 = "set16_4" +CONF_SET16_5 = "set16_5" +CONF_SET16_6 = "set16_6" +CONF_SET16_7 = "set16_7" +CONF_SET16_8 = "set16_8" +CONF_SET16_9 = "set16_9" +CONF_SET16_10 = "set16_10" +CONF_SET16_11 = "set16_11" +CONF_SET16_12 = "set16_12" +CONF_SET16_13 = "set16_13" +CONF_SET16_14 = "set16_14" +CONF_SET16_15 = "set16_15" +CONF_SET16_16 = "set16_16" +CONF_SET18 = "set18" +CONF_SET19 = "set19" +CONF_SET20 = "set20" +CONF_SET21 = "set21" +CONF_SET22 = "set22" +CONF_SET23 = "set23" +CONF_SET27 = "set27" +CONF_SET29 = "set29" +CONF_SET36 = "set36" +CONF_SET37 = "set37" +CONF_SET38 = "set38" TYPES = [ - CONF_SET_Z1_HEAT_REQUEST_TEMPERATURE, - CONF_SET_Z1_COOL_REQUEST_TEMPERATURE, - CONF_SET_Z2_HEAT_REQUEST_TEMPERATURE, - CONF_SET_Z2_COOL_REQUEST_TEMPERATURE, - CONF_SET_DHW_TEMP, - CONF_SET_MAX_PUMP_DUTY, - CONF_SET_ZONE1_HEAT_TARGET_HIGH, - CONF_SET_ZONE1_HEAT_TARGET_LOW, - CONF_SET_ZONE1_HEAT_OUTSIDE_LOW, - CONF_SET_ZONE1_HEAT_OUTSIDE_HIGH, - CONF_SET_ZONE2_HEAT_TARGET_HIGH, - CONF_SET_ZONE2_HEAT_TARGET_LOW, - CONF_SET_ZONE2_HEAT_OUTSIDE_LOW, - CONF_SET_ZONE2_HEAT_OUTSIDE_HIGH, - CONF_SET_ZONE1_COOL_TARGET_HIGH, - CONF_SET_ZONE1_COOL_TARGET_LOW, - CONF_SET_ZONE1_COOL_OUTSIDE_LOW, - CONF_SET_ZONE1_COOL_OUTSIDE_HIGH, - CONF_SET_ZONE2_COOL_TARGET_HIGH, - CONF_SET_ZONE2_COOL_TARGET_LOW, - CONF_SET_ZONE2_COOL_OUTSIDE_LOW, - CONF_SET_ZONE2_COOL_OUTSIDE_HIGH, - CONF_SET_FLOOR_HEAT_DELTA, - CONF_SET_FLOOR_COOL_DELTA, - CONF_SET_DHW_HEAT_DELTA, - CONF_SET_HEATER_DELAY_TIME, - CONF_SET_HEATER_START_DELTA, - CONF_SET_HEATER_STOP_DELTA, - CONF_SET_BUFFER_DELTA, - CONF_SET_HEATINGOFFOUTDOORTEMP, - CONF_SET_BIVALENT_START_TEMPERATURE, - CONF_SET_BIVALENT_STOP_TEMPERATURE, + CONF_SET5, + CONF_SET6, + CONF_SET7, + CONF_SET8, + CONF_SET11, + CONF_SET15, + CONF_SET16_1, + CONF_SET16_2, + CONF_SET16_3, + CONF_SET16_4, + CONF_SET16_5, + CONF_SET16_6, + CONF_SET16_7, + CONF_SET16_8, + CONF_SET16_9, + CONF_SET16_10, + CONF_SET16_11, + CONF_SET16_12, + CONF_SET16_13, + CONF_SET16_14, + CONF_SET16_15, + CONF_SET16_16, + CONF_SET18, + CONF_SET19, + CONF_SET20, + CONF_SET21, + CONF_SET22, + CONF_SET23, + CONF_SET27, + CONF_SET29, + CONF_SET36, + CONF_SET37, + CONF_SET38, +] + +# min_value, max_value, step +CONF_NUMBERS = [ + [ -5, 5, 1, ], + [ -5, 5, 1, ], + [ -5, 5, 1, ], + [ -5, 5, 1, ], + [ 40, 75, 1, ], + [ 64, 254, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ 1, 15, 1, ], + [ 1, 15, 1, ], + [ -12, -2, 1, ], + [ 0, 1000, 1, ], + [ 1, 15, 1, ], + [ 1, 15, 1, ], + [ 0, 10, 1, ], + [ 5, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], + [ -15, 35, 1, ], ] PanasonicHeatpumpNumber = panasonic_heatpump_ns.class_("PanasonicHeatpumpNumber", number.Number) @@ -82,133 +123,169 @@ CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent), - cv.Optional(CONF_SET_Z1_HEAT_REQUEST_TEMPERATURE): number.number_schema( + cv.Optional(CONF_SET5): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_Z1_COOL_REQUEST_TEMPERATURE): number.number_schema( + cv.Optional(CONF_SET6): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_Z2_HEAT_REQUEST_TEMPERATURE): number.number_schema( + cv.Optional(CONF_SET7): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_Z2_COOL_REQUEST_TEMPERATURE): number.number_schema( + cv.Optional(CONF_SET8): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_DHW_TEMP): number.number_schema( + cv.Optional(CONF_SET11): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_MAX_PUMP_DUTY): number.number_schema( + cv.Optional(CONF_SET15): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_HEAT_TARGET_HIGH): number.number_schema( + cv.Optional(CONF_SET16_1): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_HEAT_TARGET_LOW): number.number_schema( + cv.Optional(CONF_SET16_2): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_HEAT_OUTSIDE_LOW): number.number_schema( + cv.Optional(CONF_SET16_3): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_HEAT_OUTSIDE_HIGH): number.number_schema( + cv.Optional(CONF_SET16_4): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_HEAT_TARGET_HIGH): number.number_schema( + cv.Optional(CONF_SET16_5): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_HEAT_TARGET_LOW): number.number_schema( + cv.Optional(CONF_SET16_6): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_HEAT_OUTSIDE_LOW): number.number_schema( + cv.Optional(CONF_SET16_7): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_HEAT_OUTSIDE_HIGH): number.number_schema( + cv.Optional(CONF_SET16_8): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_COOL_TARGET_HIGH): number.number_schema( + cv.Optional(CONF_SET16_9): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_COOL_TARGET_LOW): number.number_schema( + cv.Optional(CONF_SET16_10): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_COOL_OUTSIDE_LOW): number.number_schema( + cv.Optional(CONF_SET16_11): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE1_COOL_OUTSIDE_HIGH): number.number_schema( + cv.Optional(CONF_SET16_12): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_COOL_TARGET_HIGH): number.number_schema( + cv.Optional(CONF_SET16_13): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_COOL_TARGET_LOW): number.number_schema( + cv.Optional(CONF_SET16_14): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_COOL_OUTSIDE_LOW): number.number_schema( + cv.Optional(CONF_SET16_15): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONE2_COOL_OUTSIDE_HIGH): number.number_schema( + cv.Optional(CONF_SET16_16): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_FLOOR_HEAT_DELTA): number.number_schema( + cv.Optional(CONF_SET18): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_KELVIN, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_FLOOR_COOL_DELTA): number.number_schema( + cv.Optional(CONF_SET19): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_KELVIN, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_DHW_HEAT_DELTA): number.number_schema( + cv.Optional(CONF_SET20): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_KELVIN, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_HEATER_DELAY_TIME): number.number_schema( + cv.Optional(CONF_SET21): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_MINUTE, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_HEATER_START_DELTA): number.number_schema( + cv.Optional(CONF_SET22): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_KELVIN, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_HEATER_STOP_DELTA): number.number_schema( + cv.Optional(CONF_SET23): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_KELVIN, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_BUFFER_DELTA): number.number_schema( + cv.Optional(CONF_SET27): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_KELVIN, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_HEATINGOFFOUTDOORTEMP): number.number_schema( + cv.Optional(CONF_SET29): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_BIVALENT_START_TEMPERATURE): number.number_schema( + cv.Optional(CONF_SET36): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_BIVALENT_STOP_TEMPERATURE): number.number_schema( + cv.Optional(CONF_SET37): number.number_schema( PanasonicHeatpumpNumber, - unit_of_measurement=UNIT_CENTIMETER, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, + ), + cv.Optional(CONF_SET38): number.number_schema( + PanasonicHeatpumpNumber, + unit_of_measurement=UNIT_CELSIUS, + entity_category=ENTITY_CATEGORY_CONFIG, ), } ) @@ -220,6 +297,7 @@ async def to_code(config): async def setup_conf(parent_config, key, hub): if child_config := parent_config.get(key): - var = await number.new_number(child_config, min_value=0, max_value=100, step=.1) + index = TYPES.index(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]) await cg.register_parented(var, parent_config[CONF_PANASONIC_HEATPUMP_ID]) cg.add(getattr(hub, f"set_{key}_number")(var)) diff --git a/components/panasonic_heatpump/panasonic_heatpump.cpp b/components/panasonic_heatpump/panasonic_heatpump.cpp index 62ed92b..839a3ca 100644 --- a/components/panasonic_heatpump/panasonic_heatpump.cpp +++ b/components/panasonic_heatpump/panasonic_heatpump.cpp @@ -158,62 +158,64 @@ namespace esphome LOG_TEXT_SENSOR("", "Panasonic Heatpump TextSensor", this->top126_text_sensor_); LOG_TEXT_SENSOR("", "Panasonic Heatpump TextSensor", this->top130_text_sensor_); #endif -#ifdef USE_BUTTON - LOG_BUTTON("", "Panasonic Heatpump Button", this->reset_button_); -#endif #ifdef USE_NUMBER - LOG_NUMBER("", "Panasonic Heatpump Number", this->z1_heat_request_temperature_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->z1_cool_request_temperature_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->z2_heat_request_temperature_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->z2_cool_request_temperature_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->dhw_temp_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->max_pump_duty_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_heat_target_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_heat_target_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_heat_outside_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_heat_outside_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_heat_target_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_heat_target_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_heat_outside_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_heat_outside_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_cool_target_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_cool_target_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_cool_outside_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone1_cool_outside_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_cool_target_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_cool_target_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_cool_outside_low_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->zone2_cool_outside_high_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->floor_heat_delta_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->floor_cool_delta_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->dhw_heat_delta_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->heater_delay_time_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->heater_start_delta_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->heater_stop_delta_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->buffer_delta_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->heatingoffoutdoortemp_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->bivalent_start_temperature_number_); - LOG_NUMBER("", "Panasonic Heatpump Number", this->bivalent_stop_temperature_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set5_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set6_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set7_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set8_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set11_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set15_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_1_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_2_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_3_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_4_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_5_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_6_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_7_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_8_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_9_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_10_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_11_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_12_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_13_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_14_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_15_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set16_16_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set18_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set19_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set20_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set21_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set22_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set23_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set27_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set29_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set36_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set37_number_); + LOG_NUMBER("", "Panasonic Heatpump Number", this->set38_number_); #endif #ifdef USE_SELECT - LOG_SELECT("", "Panasonic Heatpump Select", this->quiet_mode_select_); - LOG_SELECT("", "Panasonic Heatpump Select", this->powerful_mode_select_); - LOG_SELECT("", "Panasonic Heatpump Select", this->operation_mode_select_); - LOG_SELECT("", "Panasonic Heatpump Select", this->zones_select_); - LOG_SELECT("", "Panasonic Heatpump Select", this->external_pad_heater_select_); - LOG_SELECT("", "Panasonic Heatpump Select", this->powerful_mode2_select_); - LOG_SELECT("", "Panasonic Heatpump Select", this->bivalent_mode_select_); + LOG_SELECT("", "Panasonic Heatpump Select", this->set3_select_); + LOG_SELECT("", "Panasonic Heatpump Select", this->set4_select_); + LOG_SELECT("", "Panasonic Heatpump Select", this->set9_select_); + LOG_SELECT("", "Panasonic Heatpump Select", this->set17_select_); + LOG_SELECT("", "Panasonic Heatpump Select", this->set26_select_); + LOG_SELECT("", "Panasonic Heatpump Select", this->set35_select_); #endif #ifdef USE_SWITCH - LOG_SWITCH("", "Panasonic Heatpump Switch", this->heatpump_state_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->holiday_mode_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->force_dhw_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->force_defrost_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->force_sterilization_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->pump_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->main_schedule_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->alt_external_sensor_switch_); - LOG_SWITCH("", "Panasonic Heatpump Switch", this->buffer_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set1_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set2_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set10_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set12_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set13_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set14_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set24_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set25_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set28_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set30_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set31_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set32_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set33_switch_); + LOG_SWITCH("", "Panasonic Heatpump Switch", this->set34_switch_); #endif } @@ -309,7 +311,7 @@ namespace esphome void PanasonicHeatpumpComponent::log_uart_hex(std::string prefix, std::vector bytes, uint8_t separator) { if (this->log_uart_msg_ == false) return; - + std::string logStr; logStr = "[" + std::to_string(bytes.size()) + "]"; ESP_LOGI(TAG, "%s %s", prefix.c_str(), logStr.c_str()); @@ -538,77 +540,73 @@ namespace esphome delay(100); // NOLINT } -#ifdef USE_BUTTON - void PanasonicHeatpumpComponent::button_press_action(button::Button* object) - { - // if (object == this->reset_button_) - // this->send_request(value, index); - } -#endif #ifdef USE_NUMBER void PanasonicHeatpumpComponent::number_control(number::Number* object, float value) { - // if (object == this->z1_heat_request_temperature_number_) - // this->send_request(value, index); - // else if (object == this->z1_cool_request_temperature_number_) - // else if (object == this->z2_heat_request_temperature_number_) - // else if (object == this->z2_cool_request_temperature_number_) - // else if (object == this->dhw_temp_number_) - // else if (object == this->max_pump_duty_number_) - // else if (object == this->zone1_heat_target_high_number_) - // else if (object == this->zone1_heat_target_low_number_) - // else if (object == this->zone1_heat_outside_low_number_) - // else if (object == this->zone1_heat_outside_high_number_) - // else if (object == this->zone2_heat_target_high_number_) - // else if (object == this->zone2_heat_target_low_number_) - // else if (object == this->zone2_heat_outside_low_number_) - // else if (object == this->zone2_heat_outside_high_number_) - // else if (object == this->zone1_cool_target_high_number_) - // else if (object == this->zone1_cool_target_low_number_) - // else if (object == this->zone1_cool_outside_low_number_) - // else if (object == this->zone1_cool_outside_high_number_) - // else if (object == this->zone2_cool_target_high_number_) - // else if (object == this->zone2_cool_target_low_number_) - // else if (object == this->zone2_cool_outside_low_number_) - // else if (object == this->zone2_cool_outside_high_number_) - // else if (object == this->floor_heat_delta_number_) - // else if (object == this->floor_cool_delta_number_) - // else if (object == this->dhw_heat_delta_number_) - // else if (object == this->heater_delay_time_number_) - // else if (object == this->heater_start_delta_number_) - // else if (object == this->heater_stop_delta_number_) - // else if (object == this->buffer_delta_number_) - // else if (object == this->heatingoffoutdoortemp_number_) - // else if (object == this->bivalent_start_temperature_number_) - // else if (object == this->bivalent_stop_temperature_number_) + if (object == this->set5_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 38); + else if (object == this->set6_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 39); + else if (object == this->set7_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 40); + else if (object == this->set8_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 41); + else if (object == this->set11_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 42); + else if (object == this->set15_number_) this->send_command_message(PanasonicCommand::setPlus1(value), 45); + else if (object == this->set16_1_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 75); + else if (object == this->set16_2_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 76); + else if (object == this->set16_3_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 77); + else if (object == this->set16_4_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 78); + else if (object == this->set16_5_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 79); + else if (object == this->set16_6_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 80); + else if (object == this->set16_7_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 81); + else if (object == this->set16_8_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 82); + else if (object == this->set16_9_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 86); + else if (object == this->set16_10_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 87); + else if (object == this->set16_11_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 88); + else if (object == this->set16_12_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 89); + else if (object == this->set16_13_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 90); + else if (object == this->set16_14_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 91); + else if (object == this->set16_15_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 92); + else if (object == this->set16_16_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 93); + else if (object == this->set18_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 84); + else if (object == this->set19_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 94); + else if (object == this->set20_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 99); + else if (object == this->set21_number_) this->send_command_message(PanasonicCommand::setPlus1(value), 104); + else if (object == this->set22_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 105); + else if (object == this->set23_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 106); + else if (object == this->set27_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 59); + else if (object == this->set29_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 83); + else if (object == this->set36_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 65); + else if (object == this->set37_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 66); + else if (object == this->set38_number_) this->send_command_message(PanasonicCommand::setPlus128(value), 68); } #endif #ifdef USE_SELECT - void PanasonicHeatpumpComponent::select_control(select::Select* object, const std::string &value) + void PanasonicHeatpumpComponent::select_control(select::Select* object, size_t value) { - // if (object == this->quiet_mode_select_) - // this->send_request(value, index); - // else if (object == this->powerful_mode_select_) - // else if (object == this->operation_mode_select_) - // else if (object == this->zones_select_) - // else if (object == this->external_pad_heater_select_) - // else if (object == this->powerful_mode2_select_) - // else if (object == this->bivalent_mode_select_) + if (object == this->set3_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply8(value), 7); + else if (object == this->set4_select_) this->send_command_message(PanasonicCommand::setPlus73(value), 7); + else if (object == this->set9_select_) this->send_command_message(PanasonicCommand::setOperationMode(value), 6); + else if (object == this->set17_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply64(value), 6); + else if (object == this->set26_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply16(value), 25); + else if (object == this->set35_select_) this->send_command_message(PanasonicCommand::setPlus1Multiply4(value), 26); } #endif #ifdef USE_SWITCH void PanasonicHeatpumpComponent::switch_control(switch::Switch* object, bool state) { - // if (object == this->heatpump_state_switch_) - // this->send_request(value, index); - // else if (object == this->holiday_mode_switch_) - // else if (object == this->force_dhw_switch_) - // else if (object == this->force_defrost_switch_) - // else if (object == this->force_sterilization_switch_) - // else if (object == this->pump_switch_) - // else if (object == this->main_schedule_switch_) - // else if (object == this->alt_external_sensor_switch_) - // else if (object == this->buffer_switch_) + if (object == this->set1_switch_) this->send_command_message(PanasonicCommand::setPlus1(value), 4); + else if (object == this->set2_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply16(value), 5); + else if (object == this->set10_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply64(value), 4); + else if (object == this->set12_switch_) this->send_command_message(PanasonicCommand::setMultiply2(value), 8); + else if (object == this->set13_switch_) this->send_command_message(PanasonicCommand::setMultiply4(value), 8); + else if (object == this->set14_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply16(value), 4); + else if (object == this->set24_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply64(value), 5); + else if (object == this->set25_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply16(value), 20); + else if (object == this->set28_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply4(value), 24); + else if (object == this->set30_switch_) this->send_command_message(PanasonicCommand::setPlus1(value), 23); + else if (object == this->set31_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply16(value), 23); + else if (object == this->set32_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply64(value), 23); + else if (object == this->set33_switch_) this->send_command_message(PanasonicCommand::setPlus1Multiply4(value), 23); + else if (object == this->set34_switch_) this->send_command_message(PanasonicCommand::setPlus1(value), 26); + } #endif } // namespace panasonic_heatpump diff --git a/components/panasonic_heatpump/panasonic_heatpump.h b/components/panasonic_heatpump/panasonic_heatpump.h index fd4eb6c..67cc767 100644 --- a/components/panasonic_heatpump/panasonic_heatpump.h +++ b/components/panasonic_heatpump/panasonic_heatpump.h @@ -13,9 +13,6 @@ #ifdef USE_TEXT_SENSOR #include "esphome/components/text_sensor/text_sensor.h" #endif -#ifdef USE_BUTTON -#include "esphome/components/button/button.h" -#endif #ifdef USE_NUMBER #include "esphome/components/number/number.h" #endif @@ -38,6 +35,7 @@ namespace esphome class PanasonicHeatpumpComponent : public Component { public: + // ToDo: Add template for custom sensor classes similar to SUB_SENSOR (see Pipsolar) #ifdef USE_SENSOR SUB_SENSOR(top1); SUB_SENSOR(top5); @@ -183,68 +181,68 @@ namespace esphome SUB_TEXT_SENSOR(top126); SUB_TEXT_SENSOR(top130); #endif -#ifdef USE_BUTTON - SUB_BUTTON(reset); - - void button_press_action(button::Button* object); -#endif #ifdef USE_NUMBER - SUB_NUMBER(z1_heat_request_temperature); - SUB_NUMBER(z1_cool_request_temperature); - SUB_NUMBER(z2_heat_request_temperature); - SUB_NUMBER(z2_cool_request_temperature); - SUB_NUMBER(dhw_temp); - SUB_NUMBER(max_pump_duty); - SUB_NUMBER(zone1_heat_target_high); - SUB_NUMBER(zone1_heat_target_low); - SUB_NUMBER(zone1_heat_outside_low); - SUB_NUMBER(zone1_heat_outside_high); - SUB_NUMBER(zone2_heat_target_high); - SUB_NUMBER(zone2_heat_target_low); - SUB_NUMBER(zone2_heat_outside_low); - SUB_NUMBER(zone2_heat_outside_high); - SUB_NUMBER(zone1_cool_target_high); - SUB_NUMBER(zone1_cool_target_low); - SUB_NUMBER(zone1_cool_outside_low); - SUB_NUMBER(zone1_cool_outside_high); - SUB_NUMBER(zone2_cool_target_high); - SUB_NUMBER(zone2_cool_target_low); - SUB_NUMBER(zone2_cool_outside_low); - SUB_NUMBER(zone2_cool_outside_high); - SUB_NUMBER(floor_heat_delta); - SUB_NUMBER(floor_cool_delta); - SUB_NUMBER(dhw_heat_delta); - SUB_NUMBER(heater_delay_time); - SUB_NUMBER(heater_start_delta); - SUB_NUMBER(heater_stop_delta); - SUB_NUMBER(buffer_delta); - SUB_NUMBER(heatingoffoutdoortemp); - SUB_NUMBER(bivalent_start_temperature); - SUB_NUMBER(bivalent_stop_temperature); + SUB_NUMBER(set5); + SUB_NUMBER(set6); + SUB_NUMBER(set7); + SUB_NUMBER(set8); + SUB_NUMBER(set11); + SUB_NUMBER(set15); + SUB_NUMBER(set16_1); + SUB_NUMBER(set16_2); + SUB_NUMBER(set16_3); + SUB_NUMBER(set16_4); + SUB_NUMBER(set16_5); + SUB_NUMBER(set16_6); + SUB_NUMBER(set16_7); + SUB_NUMBER(set16_8); + SUB_NUMBER(set16_9); + SUB_NUMBER(set16_10); + SUB_NUMBER(set16_11); + SUB_NUMBER(set16_12); + SUB_NUMBER(set16_13); + SUB_NUMBER(set16_14); + SUB_NUMBER(set16_15); + SUB_NUMBER(set16_16); + SUB_NUMBER(set18); + SUB_NUMBER(set19); + SUB_NUMBER(set20); + SUB_NUMBER(set21); + SUB_NUMBER(set22); + SUB_NUMBER(set23); + SUB_NUMBER(set27); + SUB_NUMBER(set29); + SUB_NUMBER(set36); + SUB_NUMBER(set37); + SUB_NUMBER(set38); void number_control(number::Number* object, float value); #endif #ifdef USE_SELECT - SUB_SELECT(quiet_mode); - SUB_SELECT(powerful_mode); - SUB_SELECT(operation_mode); - SUB_SELECT(zones); - SUB_SELECT(external_pad_heater); - SUB_SELECT(powerful_mode2); - SUB_SELECT(bivalent_mode); + SUB_SELECT(set3); + SUB_SELECT(set4); + SUB_SELECT(set9); + SUB_SELECT(set17); + SUB_SELECT(set26); + SUB_SELECT(set35); - void select_control(select::Select* object, const std::string &value); + void select_control(select::Select* object, size_t value); #endif #ifdef USE_SWITCH - SUB_SWITCH(heatpump_state); - SUB_SWITCH(holiday_mode); - SUB_SWITCH(force_dhw); - SUB_SWITCH(force_defrost); - SUB_SWITCH(force_sterilization); - SUB_SWITCH(pump); - SUB_SWITCH(main_schedule); - SUB_SWITCH(alt_external_sensor); - SUB_SWITCH(buffer); + SUB_SWITCH(set1); + SUB_SWITCH(set2); + SUB_SWITCH(set10); + SUB_SWITCH(set12); + SUB_SWITCH(set13); + SUB_SWITCH(set14); + SUB_SWITCH(set24); + SUB_SWITCH(set25); + SUB_SWITCH(set28); + SUB_SWITCH(set30); + SUB_SWITCH(set31); + SUB_SWITCH(set32); + SUB_SWITCH(set33); + SUB_SWITCH(set34); void switch_control(switch::Switch* object, bool state); #endif diff --git a/components/panasonic_heatpump/select/__init__.py b/components/panasonic_heatpump/select/__init__.py index 37686d8..d6b789d 100644 --- a/components/panasonic_heatpump/select/__init__.py +++ b/components/panasonic_heatpump/select/__init__.py @@ -2,27 +2,35 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import select from esphome.const import ( - UNIT_PERCENT, + ENTITY_CATEGORY_CONFIG, ) from .. import CONF_PANASONIC_HEATPUMP_ID, PanasonicHeatpumpComponent, panasonic_heatpump_ns -CONF_SET_QUIET_MODE = "quiet_mode" -CONF_SET_POWERFUL_MODE = "powerful_mode" -CONF_SET_OPERATION_MODE = "operation_mode" -CONF_SET_ZONES = "zones" -CONF_SET_EXTERNAL_PAD_HEATER = "external_pad_heater" -CONF_SET_POWERFUL_MODE2 = "powerful_mode2" -CONF_SET_BIVALENT_MODE = "bivalent_mode" +CONF_SET3 = "set3" +CONF_SET4 = "set4" +CONF_SET9 = "set9" +CONF_SET17 = "set17" +CONF_SET26 = "set26" +CONF_SET35 = "set35" TYPES = [ - CONF_SET_QUIET_MODE, - CONF_SET_POWERFUL_MODE, - CONF_SET_OPERATION_MODE, - CONF_SET_ZONES, - CONF_SET_EXTERNAL_PAD_HEATER, - CONF_SET_POWERFUL_MODE2, - CONF_SET_BIVALENT_MODE, + CONF_SET3, + CONF_SET4, + CONF_SET9, + CONF_SET17, + CONF_SET26, + CONF_SET35, +] + +CONF_SELECTS = [ + [ "Off mode", "Quiet mode 1", "Quiet mode 2", "Quiet mode 3", ], + [ "off", "30min", "60min", "90min", ], + [ "off", "30min", "60min", "90min", ], + [ "Heat only", "Cool only", "Auto", "DHW only", "Heat+DHW", "Cool+DHW", "Auto + DHW", ], + [ "Zone 1", "Zone2", "Zone1 and Zone2", ], + [ "Disabled", "Type-A", "Type-B" ], + [ "Alternativ", "Parallel", "Advanced Parallel" ], ] PanasonicHeatpumpSelect = panasonic_heatpump_ns.class_("PanasonicHeatpumpSelect", select.Select) @@ -31,26 +39,29 @@ CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent), - cv.Optional(CONF_SET_QUIET_MODE): select.select_schema( + cv.Optional(CONF_SET3): select.select_schema( PanasonicHeatpumpSelect, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_POWERFUL_MODE): select.select_schema( + cv.Optional(CONF_SET4): select.select_schema( PanasonicHeatpumpSelect, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_OPERATION_MODE): select.select_schema( + cv.Optional(CONF_SET9): select.select_schema( PanasonicHeatpumpSelect, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ZONES): select.select_schema( + cv.Optional(CONF_SET17): select.select_schema( PanasonicHeatpumpSelect, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_EXTERNAL_PAD_HEATER): select.select_schema( + cv.Optional(CONF_SET26): select.select_schema( PanasonicHeatpumpSelect, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_POWERFUL_MODE2): select.select_schema( - PanasonicHeatpumpSelect, - ), - cv.Optional(CONF_SET_BIVALENT_MODE): select.select_schema( + cv.Optional(CONF_SET35): select.select_schema( PanasonicHeatpumpSelect, + entity_category=ENTITY_CATEGORY_CONFIG, ), } ) @@ -62,6 +73,7 @@ async def to_code(config): async def setup_conf(parent_config, key, hub): if child_config := parent_config.get(key): - var = await select.new_select(child_config, options=["dummy1", "dummy2"]) + index = TYPES.index(key) + var = await select.new_select(child_config, options=CONF_SELECTS[index]) await cg.register_parented(var, parent_config[CONF_PANASONIC_HEATPUMP_ID]) cg.add(getattr(hub, f"set_{key}_select")(var)) diff --git a/components/panasonic_heatpump/select/panasonic_heatpump_select.cpp b/components/panasonic_heatpump/select/panasonic_heatpump_select.cpp index 4353937..8f86010 100644 --- a/components/panasonic_heatpump/select/panasonic_heatpump_select.cpp +++ b/components/panasonic_heatpump/select/panasonic_heatpump_select.cpp @@ -8,7 +8,9 @@ namespace esphome void PanasonicHeatpumpSelect::control(const std::string &value) { this->publish_state(value); - this->parent_->select_control(this, value); + auto index = this->active_index(); + if (index.has_value()) + this->parent_->select_control(this, index.value()); } } // namespace panasonic_heatpump } // namespace esphome diff --git a/components/panasonic_heatpump/switch/__init__.py b/components/panasonic_heatpump/switch/__init__.py index 29136c8..796fd4b 100644 --- a/components/panasonic_heatpump/switch/__init__.py +++ b/components/panasonic_heatpump/switch/__init__.py @@ -2,31 +2,41 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import switch from esphome.const import ( - UNIT_PERCENT, + ENTITY_CATEGORY_CONFIG, ) from .. import CONF_PANASONIC_HEATPUMP_ID, PanasonicHeatpumpComponent, panasonic_heatpump_ns -CONF_SET_HEATPUMP_STATE = "heatpump_state" -CONF_SET_HOLIDAY_MODE = "holiday_mode" -CONF_SET_FORCE_DHW = "force_dhw" -CONF_SET_FORCE_DEFROST = "force_defrost" -CONF_SET_FORCE_STERILIZATION = "force_sterilization" -CONF_SET_PUMP = "pump" -CONF_SET_MAIN_SCHEDULE = "main_schedule" -CONF_SET_ALT_EXTERNAL_SENSOR = "alt_external_sensor" -CONF_SET_BUFFER = "buffer" +CONF_SET1 = "set1" +CONF_SET2 = "set2" +CONF_SET10 = "set10" +CONF_SET12 = "set12" +CONF_SET13 = "set13" +CONF_SET14 = "set14" +CONF_SET24 = "set24" +CONF_SET25 = "set25" +CONF_SET28 = "set28" +CONF_SET30 = "set30" +CONF_SET31 = "set31" +CONF_SET32 = "set32" +CONF_SET33 = "set33" +CONF_SET34 = "set34" TYPES = [ - CONF_SET_HEATPUMP_STATE, - CONF_SET_HOLIDAY_MODE, - CONF_SET_FORCE_DHW, - CONF_SET_FORCE_DEFROST, - CONF_SET_FORCE_STERILIZATION, - CONF_SET_PUMP, - CONF_SET_MAIN_SCHEDULE, - CONF_SET_ALT_EXTERNAL_SENSOR, - CONF_SET_BUFFER, + CONF_SET1, + CONF_SET2, + CONF_SET10, + CONF_SET12, + CONF_SET13, + CONF_SET14, + CONF_SET24, + CONF_SET25, + CONF_SET28, + CONF_SET30, + CONF_SET31, + CONF_SET32, + CONF_SET33, + CONF_SET34, ] PanasonicHeatpumpSwitch = panasonic_heatpump_ns.class_("PanasonicHeatpumpSwitch", switch.Switch) @@ -35,32 +45,61 @@ CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(CONF_PANASONIC_HEATPUMP_ID): cv.use_id(PanasonicHeatpumpComponent), - cv.Optional(CONF_SET_HEATPUMP_STATE): switch.switch_schema( + cv.Optional(CONF_SET1): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_HOLIDAY_MODE): switch.switch_schema( + cv.Optional(CONF_SET2): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_FORCE_DHW): switch.switch_schema( + cv.Optional(CONF_SET10): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_FORCE_DEFROST): switch.switch_schema( + cv.Optional(CONF_SET12): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_FORCE_STERILIZATION): switch.switch_schema( + cv.Optional(CONF_SET13): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_PUMP): switch.switch_schema( + cv.Optional(CONF_SET14): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_MAIN_SCHEDULE): switch.switch_schema( + cv.Optional(CONF_SET24): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_ALT_EXTERNAL_SENSOR): switch.switch_schema( + cv.Optional(CONF_SET25): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), - cv.Optional(CONF_SET_BUFFER): switch.switch_schema( + cv.Optional(CONF_SET28): switch.switch_schema( PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, + ), + cv.Optional(CONF_SET30): switch.switch_schema( + PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, + ), + cv.Optional(CONF_SET31): switch.switch_schema( + PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, + ), + cv.Optional(CONF_SET32): switch.switch_schema( + PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, + ), + cv.Optional(CONF_SET33): switch.switch_schema( + PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, + ), + cv.Optional(CONF_SET34): switch.switch_schema( + PanasonicHeatpumpSwitch, + entity_category=ENTITY_CATEGORY_CONFIG, ), } )