Skip to content

Commit

Permalink
[Bug] Fix the Coolix fan-only mode in IRac class. (#2104)
Browse files Browse the repository at this point in the history
Mode was being incorrectly set in produced message as a "Dry" command.
Adjusting order of when setMode() was called fixes the issue.
Add a Unit test to confirm it is fixed and catch this in future.

Fixes #2103
  • Loading branch information
crankyoldgit authored Jun 6, 2024
1 parent 0b0fe77 commit 9785cb9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,10 @@ void IRac::coolix(IRCoolixAC *ac,
ac->send();
return;
}
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
// Mode needs to be set after temp as Fan-only uses a special temp.
ac->setMode(ac->convertMode(mode));
// Fan needs to be set after mode, as setMode can change the fan speed.
ac->setFan(ac->convertFan(fan));
// No Filter setting available.
// No Beep setting available.
Expand Down
30 changes: 30 additions & 0 deletions test/IRac_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,36 @@ TEST(TestIRac, Coolix) {
ASSERT_EQ(stdAc::ac_command_t::kControlCommand, r.command);
}

TEST(TestIRac, Coolix_Issue2103) {
IRCoolixAC ac(kGpioUnused);
IRac irac(kGpioUnused);
IRrecv capture(kGpioUnused);
char expected[] =
"Power: On, Mode: 4 (Fan), Fan: 5 (Auto), Zone Follow: Off, "
"Sensor Temp: Off";

ac.begin();
irac.coolix(&ac,
true, // Power
stdAc::opmode_t::kFan, // Mode
21, // Celsius
kNoTempValue, // Sensor Temp
stdAc::fanspeed_t::kAuto, // Fan speed
stdAc::swingv_t::kOff, // Vertical swing
stdAc::swingh_t::kOff, // Horizontal swing
false, // iFeel
false, // Turbo
false, // Light
false, // Clean
-1); // Sleep
ASSERT_EQ(expected, ac.toString());
ac._irsend.makeDecodeResult();
EXPECT_TRUE(capture.decode(&ac._irsend.capture));
ASSERT_EQ(COOLIX, ac._irsend.capture.decode_type);
ASSERT_EQ(kCoolixBits, ac._irsend.capture.bits);
ASSERT_EQ(expected, IRAcUtils::resultAcToString(&ac._irsend.capture));
}

TEST(TestIRac, Corona) {
IRCoronaAc ac(kGpioUnused);
IRac irac(kGpioUnused);
Expand Down

0 comments on commit 9785cb9

Please sign in to comment.