From 772860d3533ea1cee53da2de046a4c9004c93194 Mon Sep 17 00:00:00 2001 From: ElVit Date: Mon, 3 Feb 2025 14:09:36 +0100 Subject: [PATCH] fixed comile error caused by switch::Switch. Renamed getBoolState to getBinaryState --- components/panasonic_heatpump/__init__.py | 2 +- components/panasonic_heatpump/decode.cpp | 2 +- components/panasonic_heatpump/decode.h | 2 +- .../panasonic_heatpump/panasonic_heatpump.cpp | 49 +++++++++---------- .../panasonic_heatpump/panasonic_heatpump.h | 2 +- .../switch/panasonic_heatpump_switch.cpp | 3 +- .../switch/panasonic_heatpump_switch.h | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/components/panasonic_heatpump/__init__.py b/components/panasonic_heatpump/__init__.py index 72dc8be..e6de1c4 100644 --- a/components/panasonic_heatpump/__init__.py +++ b/components/panasonic_heatpump/__init__.py @@ -24,7 +24,7 @@ CONFIG_SCHEMA = ( cv.Required(CONF_UART_HP): cv.use_id(uart.UARTComponent), cv.Required(CONF_UART_WM): cv.use_id(uart.UARTComponent), cv.Optional(CONF_LOG_UART_MSG, default=False): cv.boolean, - cv.Optional(CONF_POLLING_TIME_SEC, default=1): cv.int_range(min=1), + cv.Optional(CONF_POLLING_TIME_SEC, default=2): cv.int_range(min=1), } ) .extend(cv.COMPONENT_SCHEMA) diff --git a/components/panasonic_heatpump/decode.cpp b/components/panasonic_heatpump/decode.cpp index 90abd57..cf13eeb 100644 --- a/components/panasonic_heatpump/decode.cpp +++ b/components/panasonic_heatpump/decode.cpp @@ -307,7 +307,7 @@ namespace esphome return error_string; } - bool PanasonicDecode::getBoolState(uint8_t input) + bool PanasonicDecode::getBinaryState(uint8_t input) { return input != 0; } diff --git a/components/panasonic_heatpump/decode.h b/components/panasonic_heatpump/decode.h index d54053b..567f58a 100644 --- a/components/panasonic_heatpump/decode.h +++ b/components/panasonic_heatpump/decode.h @@ -43,7 +43,7 @@ namespace esphome static float getFractional(uint8_t input, uint8_t shift); static std::string getErrorInfo(uint8_t errorType, uint8_t errorNumber); - static bool getBoolState(uint8_t input); + static bool getBinaryState(uint8_t input); static std::string getTextState(const char* const array[], int index); static const constexpr char* const DisabledEnabled[] = {"2", "Disabled", "Enabled"}; diff --git a/components/panasonic_heatpump/panasonic_heatpump.cpp b/components/panasonic_heatpump/panasonic_heatpump.cpp index 839a3ca..d398517 100644 --- a/components/panasonic_heatpump/panasonic_heatpump.cpp +++ b/components/panasonic_heatpump/panasonic_heatpump.cpp @@ -459,29 +459,29 @@ namespace esphome if (this->top138_sensor_) this->top138_sensor_->publish_state(PanasonicDecode::getIntMinus1(bytes[70])); #endif #ifdef USE_BINARY_SENSOR - if (this->top0_binary_sensor_) this->top0_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit7and8(bytes[4]))); - if (this->top2_binary_sensor_) this->top2_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit1and2(bytes[4]))); - if (this->top3_binary_sensor_) this->top3_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit1and2(bytes[7]))); - if (this->top13_binary_sensor_) this->top13_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit1and2(bytes[5]))); - if (this->top26_binary_sensor_) this->top26_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit5and6(bytes[111]))); - if (this->top60_binary_sensor_) this->top60_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit7and8(bytes[112]))); - if (this->top61_binary_sensor_) this->top61_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit5and6(bytes[112]))); - if (this->top68_binary_sensor_) this->top68_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit5and6(bytes[5]))); - if (this->top69_binary_sensor_) this->top69_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit5and6(bytes[117]))); - if (this->top99_binary_sensor_) this->top99_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit5and6(bytes[24]))); - if (this->top100_binary_sensor_) this->top100_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit7and8(bytes[24]))); - if (this->top108_binary_sensor_) this->top108_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit3and4(bytes[20]))); - if (this->top109_binary_sensor_) this->top109_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit5and6(bytes[20]))); - if (this->top110_binary_sensor_) this->top110_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit7and8(bytes[20]))); - if (this->top119_binary_sensor_) this->top119_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit7and8(bytes[23]))); - if (this->top120_binary_sensor_) this->top120_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit5and6(bytes[23]))); - if (this->top121_binary_sensor_) this->top121_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit3and4(bytes[23]))); - if (this->top122_binary_sensor_) this->top122_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit1and2(bytes[23]))); - if (this->top123_binary_sensor_) this->top123_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit1and2(bytes[116]))); - if (this->top124_binary_sensor_) this->top124_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit3and4(bytes[116]))); - if (this->top129_binary_sensor_) this->top129_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit7and8(bytes[26]))); - if (this->top132_binary_sensor_) this->top132_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit3and4(bytes[26]))); - if (this->top133_binary_sensor_) this->top133_binary_sensor_->publish_state(PanasonicDecode::getBoolState(PanasonicDecode::getBit1and2(bytes[26]))); + 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]))); + if (this->top3_binary_sensor_) this->top3_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[7]))); + if (this->top13_binary_sensor_) this->top13_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[5]))); + if (this->top26_binary_sensor_) this->top26_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[111]))); + if (this->top60_binary_sensor_) this->top60_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[112]))); + if (this->top61_binary_sensor_) this->top61_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[112]))); + if (this->top68_binary_sensor_) this->top68_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[5]))); + if (this->top69_binary_sensor_) this->top69_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[117]))); + if (this->top99_binary_sensor_) this->top99_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[24]))); + if (this->top100_binary_sensor_) this->top100_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[24]))); + if (this->top108_binary_sensor_) this->top108_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(bytes[20]))); + if (this->top109_binary_sensor_) this->top109_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[20]))); + if (this->top110_binary_sensor_) this->top110_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[20]))); + if (this->top119_binary_sensor_) this->top119_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[23]))); + if (this->top120_binary_sensor_) this->top120_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit5and6(bytes[23]))); + if (this->top121_binary_sensor_) this->top121_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(bytes[23]))); + if (this->top122_binary_sensor_) this->top122_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[23]))); + if (this->top123_binary_sensor_) this->top123_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit1and2(bytes[116]))); + if (this->top124_binary_sensor_) this->top124_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit3and4(bytes[116]))); + if (this->top129_binary_sensor_) this->top129_binary_sensor_->publish_state(PanasonicDecode::getBinaryState(PanasonicDecode::getBit7and8(bytes[26]))); + 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 #ifdef USE_TEXT_SENSOR if (this->top4_text_sensor_) this->top4_text_sensor_->publish_state(PanasonicDecode::getTextState(PanasonicDecode::OpModeDesc, PanasonicDecode::getOpMode(bytes[6]))); @@ -590,7 +590,7 @@ namespace esphome } #endif #ifdef USE_SWITCH - void PanasonicHeatpumpComponent::switch_control(switch::Switch* object, bool state) + void PanasonicHeatpumpComponent::switch_control(switch_::Switch* object, size_t value) { 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); @@ -606,7 +606,6 @@ namespace esphome 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 67cc767..09609bb 100644 --- a/components/panasonic_heatpump/panasonic_heatpump.h +++ b/components/panasonic_heatpump/panasonic_heatpump.h @@ -244,7 +244,7 @@ namespace esphome SUB_SWITCH(set33); SUB_SWITCH(set34); - void switch_control(switch::Switch* object, bool state); + void switch_control(switch_::Switch* object, size_t value); #endif PanasonicHeatpumpComponent() = default; diff --git a/components/panasonic_heatpump/switch/panasonic_heatpump_switch.cpp b/components/panasonic_heatpump/switch/panasonic_heatpump_switch.cpp index 2c4f3ac..7df2095 100644 --- a/components/panasonic_heatpump/switch/panasonic_heatpump_switch.cpp +++ b/components/panasonic_heatpump/switch/panasonic_heatpump_switch.cpp @@ -8,7 +8,8 @@ namespace esphome void PanasonicHeatpumpSwitch::write_state(bool state) { this->publish_state(state); - this->parent_->switch_control(this, state); + size_t value = state ? 1 : 0; + this->parent_->switch_control(this, value); } } // namespace panasonic_heatpump } // namespace esphome diff --git a/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h b/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h index 3686116..be2c470 100644 --- a/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h +++ b/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h @@ -7,7 +7,7 @@ namespace esphome { namespace panasonic_heatpump { - class PanasonicHeatpumpSwitch : public switch::Switch, public Parented + class PanasonicHeatpumpSwitch : public switch_::Switch, public Parented { public: PanasonicHeatpumpSwitch() = default;