From 609abce2166775ac4e8267b6e0da69b7bbabd6d5 Mon Sep 17 00:00:00 2001 From: David Conran Date: Wed, 23 Jun 2021 16:38:32 +1000 Subject: [PATCH] IRac: Change Coolix to send special messages after a normal message. (#1502) Sending a special message after a normal message ensures the unit is on. Reports are that if a state with special setting (e.g. Turbo) and turning the unit on, the special message is ignored because the unit must be powered on before it will accept it. So, change the order, send the normal state first, then the special message/settings, except for "Off" of course. Fixes #1501 --- src/IRac.cpp | 8 ++++++- test/IRac_test.cpp | 53 ++++++++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/IRac.cpp b/src/IRac.cpp index 316d7562a..97fd695e3 100644 --- a/src/IRac.cpp +++ b/src/IRac.cpp @@ -450,6 +450,13 @@ void IRac::coolix(IRCoolixAC *ac, // No Clock setting available. // No Econo setting available. // No Quiet setting available. + ac->send(); // Send the state, which will also power on the unit. + // The following are all options/settings that create their own special + // messages. Often they only make sense to be sent after the unit is turned + // on. For instance, assuming a person wants to have the a/c on and in turbo + // mode. If we send the turbo message, it is ignored if the unit is off. + // Hence we send the special mode/setting messages after a normal message + // which will turn on the device. if (swingv != stdAc::swingv_t::kOff || swingh != stdAc::swingh_t::kOff) { // Swing has a special command that needs to be sent independently. ac->setSwing(); @@ -475,7 +482,6 @@ void IRac::coolix(IRCoolixAC *ac, ac->setClean(); ac->send(); } - ac->send(); } #endif // SEND_COOLIX diff --git a/test/IRac_test.cpp b/test/IRac_test.cpp index abbb9cca1..a6e0be3ac 100644 --- a/test/IRac_test.cpp +++ b/test/IRac_test.cpp @@ -2148,37 +2148,28 @@ TEST(TestIRac, Issue821) { result.mode, // Mode result.degrees, // Celsius result.fanspeed, // Fan speed - result.swingv, // Vertical swing - result.swingh, // Horizontal swing - result.turbo, // Turbo - result.light, // Light - result.clean, // Clean - -1); // Sleep - ac._irsend.makeDecodeResult(); + result.swingv, // Vertical swing + result.swingh, // Horizontal swing + result.turbo, // Turbo + result.light, // Light + result.clean, // Clean + -1); // Sleep + ac._irsend.makeDecodeResult(); + // We expect a normal state message, followed by the special "light" message. EXPECT_TRUE(capture.decode(&ac._irsend.capture)); ASSERT_EQ(COOLIX, ac._irsend.capture.decode_type); ASSERT_EQ(kCoolixBits, ac._irsend.capture.bits); + ASSERT_EQ("Power: On, Mode: 2 (Auto), Fan: 0 (Auto0), Temp: 24C, " + "Zone Follow: Off, Sensor Temp: Off", + IRAcUtils::resultAcToString(&ac._irsend.capture)); + EXPECT_TRUE(capture.decodeCOOLIX(&ac._irsend.capture, 201)); + ASSERT_EQ(COOLIX, ac._irsend.capture.decode_type); + ASSERT_EQ(kCoolixBits, ac._irsend.capture.bits); ASSERT_EQ("Power: On, Light: Toggle", IRAcUtils::resultAcToString(&ac._irsend.capture)); EXPECT_EQ( "f38000d50" "m4692s4416" - "m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552m552s1656" - "m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656m552s552" - "m552s1656m552s1656m552s1656m552s1656m552s552m552s1656m552s552m552s1656" - "m552s552m552s552m552s552m552s552m552s1656m552s552m552s1656m552s552" - "m552s1656m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656" - "m552s552m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552" - "m552s5244" - "m4692s4416" - "m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552m552s1656" - "m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656m552s552" - "m552s1656m552s1656m552s1656m552s1656m552s552m552s1656m552s552m552s1656" - "m552s552m552s552m552s552m552s552m552s1656m552s552m552s1656m552s552" - "m552s1656m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656" - "m552s552m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552" - "m552s105244" - "m4692s4416" "m552s1656m552s552m552s1656m552s1656m552s552m552s552m552s1656m552s552" "m552s552m552s1656m552s552m552s552m552s1656m552s1656m552s552m552s1656" "m552s552m552s552m552s552m552s1656m552s1656m552s1656m552s1656m552s1656" @@ -2193,6 +2184,22 @@ TEST(TestIRac, Issue821) { "m552s1656m552s1656m552s1656m552s552m552s552m552s552m552s552m552s552" "m552s552m552s1656m552s552m552s552m552s1656m552s552m552s552m552s552" "m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s1656m552s1656" + "m552s105244" + "m4692s4416" + "m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552m552s1656" + "m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656m552s552" + "m552s1656m552s1656m552s1656m552s1656m552s552m552s1656m552s552m552s1656" + "m552s552m552s552m552s552m552s552m552s1656m552s552m552s1656m552s552" + "m552s1656m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656" + "m552s552m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552" + "m552s5244" + "m4692s4416" + "m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552m552s1656" + "m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656m552s552" + "m552s1656m552s1656m552s1656m552s1656m552s552m552s1656m552s552m552s1656" + "m552s552m552s552m552s552m552s552m552s1656m552s552m552s1656m552s552" + "m552s1656m552s552m552s1656m552s552m552s552m552s1656m552s552m552s1656" + "m552s552m552s1656m552s552m552s1656m552s1656m552s552m552s1656m552s552" "m552s105244", ac._irsend.outputStr()); }