Skip to content

Commit 9785cb9

Browse files
authored
[Bug] Fix the Coolix fan-only mode in IRac class. (#2104)
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
1 parent 0b0fe77 commit 9785cb9

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/IRac.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,10 @@ void IRac::coolix(IRCoolixAC *ac,
736736
ac->send();
737737
return;
738738
}
739-
ac->setMode(ac->convertMode(mode));
740739
ac->setTemp(degrees);
740+
// Mode needs to be set after temp as Fan-only uses a special temp.
741+
ac->setMode(ac->convertMode(mode));
742+
// Fan needs to be set after mode, as setMode can change the fan speed.
741743
ac->setFan(ac->convertFan(fan));
742744
// No Filter setting available.
743745
// No Beep setting available.

test/IRac_test.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,36 @@ TEST(TestIRac, Coolix) {
247247
ASSERT_EQ(stdAc::ac_command_t::kControlCommand, r.command);
248248
}
249249

250+
TEST(TestIRac, Coolix_Issue2103) {
251+
IRCoolixAC ac(kGpioUnused);
252+
IRac irac(kGpioUnused);
253+
IRrecv capture(kGpioUnused);
254+
char expected[] =
255+
"Power: On, Mode: 4 (Fan), Fan: 5 (Auto), Zone Follow: Off, "
256+
"Sensor Temp: Off";
257+
258+
ac.begin();
259+
irac.coolix(&ac,
260+
true, // Power
261+
stdAc::opmode_t::kFan, // Mode
262+
21, // Celsius
263+
kNoTempValue, // Sensor Temp
264+
stdAc::fanspeed_t::kAuto, // Fan speed
265+
stdAc::swingv_t::kOff, // Vertical swing
266+
stdAc::swingh_t::kOff, // Horizontal swing
267+
false, // iFeel
268+
false, // Turbo
269+
false, // Light
270+
false, // Clean
271+
-1); // Sleep
272+
ASSERT_EQ(expected, ac.toString());
273+
ac._irsend.makeDecodeResult();
274+
EXPECT_TRUE(capture.decode(&ac._irsend.capture));
275+
ASSERT_EQ(COOLIX, ac._irsend.capture.decode_type);
276+
ASSERT_EQ(kCoolixBits, ac._irsend.capture.bits);
277+
ASSERT_EQ(expected, IRAcUtils::resultAcToString(&ac._irsend.capture));
278+
}
279+
250280
TEST(TestIRac, Corona) {
251281
IRCoronaAc ac(kGpioUnused);
252282
IRac irac(kGpioUnused);

0 commit comments

Comments
 (0)