diff --git a/src/ir_Haier.cpp b/src/ir_Haier.cpp index a43e9400d..be737827d 100644 --- a/src/ir_Haier.cpp +++ b/src/ir_Haier.cpp @@ -443,7 +443,7 @@ stdAc::state_t IRHaierAC::toCommon(void) const { result.econo = false; result.light = false; result.clean = false; - result.beep = false; + result.beep = true; result.clock = -1; return result; } @@ -948,6 +948,20 @@ stdAc::swingv_t IRHaierAC176::toCommonSwingV(const uint8_t pos) { } } +/// Convert the Turbo setting of the A/C into native turbo setting. +/// @param[in] speed The enum to be converted. +/// @return true, the setting is on. false, the setting is off. +bool IRHaierAC176::toCommonTurbo(const uint8_t speed) { + return speed == kHaierAcYrw02TurboHigh; +} + +/// Convert the Turbo setting of the A/C into native quiet setting. +/// @param[in] speed The enum to be converted. +/// @return true, the setting is on. false, the setting is off. +bool IRHaierAC176::toCommonQuiet(const uint8_t speed) { + return speed == kHaierAcYrw02TurboLow; +} + /// Convert the current internal state into its stdAc::state_t equivalent. /// @return The stdAc equivalent of the native settings. stdAc::state_t IRHaierAC176::toCommon(void) const { @@ -962,14 +976,14 @@ stdAc::state_t IRHaierAC176::toCommon(void) const { result.swingv = toCommonSwingV(_.Swing); result.filter = _.Health; result.sleep = _.Sleep ? 0 : -1; + result.quiet = toCommonQuiet(_.Turbo); + result.turbo = toCommonTurbo(_.Turbo); // Not supported. result.swingh = stdAc::swingh_t::kOff; - result.quiet = false; - result.turbo = false; result.econo = false; result.light = false; result.clean = false; - result.beep = false; + result.beep = true; result.clock = -1; return result; } diff --git a/src/ir_Haier.h b/src/ir_Haier.h index 2e287cd12..64af98dd6 100644 --- a/src/ir_Haier.h +++ b/src/ir_Haier.h @@ -244,7 +244,7 @@ union HaierAc176Protocol{ uint8_t Fan :3; // Byte 6 uint8_t OffTimerMins:6; - uint8_t Turbo:2; + uint8_t Turbo :2; // Byte 7 uint8_t OnTimerHrs :5; uint8_t Mode :3; @@ -445,6 +445,8 @@ class IRHaierAC176 { static stdAc::opmode_t toCommonMode(const uint8_t mode); static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed); static stdAc::swingv_t toCommonSwingV(const uint8_t pos); + static bool toCommonTurbo(const uint8_t speed); + static bool toCommonQuiet(const uint8_t speed); stdAc::state_t toCommon(void) const; String toString(void) const; #ifndef UNIT_TEST diff --git a/test/ir_Haier_test.cpp b/test/ir_Haier_test.cpp index 8b89b1098..d066bede6 100644 --- a/test/ir_Haier_test.cpp +++ b/test/ir_Haier_test.cpp @@ -1102,7 +1102,7 @@ TEST(TestHaierACClass, toCommon) { ASSERT_FALSE(ac.toCommon().quiet); ASSERT_FALSE(ac.toCommon().econo); ASSERT_FALSE(ac.toCommon().clean); - ASSERT_FALSE(ac.toCommon().beep); + ASSERT_TRUE(ac.toCommon().beep); ASSERT_EQ(-1, ac.toCommon().clock); } @@ -1133,7 +1133,7 @@ TEST(TestHaierACYRW02Class, toCommon) { ASSERT_FALSE(ac.toCommon().quiet); ASSERT_FALSE(ac.toCommon().econo); ASSERT_FALSE(ac.toCommon().clean); - ASSERT_FALSE(ac.toCommon().beep); + ASSERT_TRUE(ac.toCommon().beep); ASSERT_EQ(-1, ac.toCommon().clock); }