Skip to content

Commit

Permalink
[BUG] Ensure IRCoolixAC::toCommon() returns kNoTempValue when no …
Browse files Browse the repository at this point in the history
…sensor temp is detected.

It seems we were reporting an incorrect sensor temp (31) which normally means "There is no sensor temp.", instead of `kNoTempValue`.

Fixes #2012
  • Loading branch information
crankyoldgit committed Jul 26, 2023
1 parent 75f9769 commit 2e66680
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ir_Coolix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ stdAc::state_t IRCoolixAC::toCommon(const stdAc::state_t *prev) const {
result.mode = toCommonMode(getMode());
result.degrees = getTemp();
result.sensorTemperature = getSensorTemp();
if (result.sensorTemperature == kCoolixSensorTempIgnoreCode) {
result.sensorTemperature = kNoTempValue;
}
result.iFeel = getZoneFollow();
result.fanspeed = toCommonFanSpeed(getFan());
return result;
Expand Down
36 changes: 36 additions & 0 deletions test/ir_Coolix_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ TEST(TestCoolixACClass, SetGetClearSensorTempAndZoneFollow) {
EXPECT_EQ(
"Power: On, Mode: 3 (Heat), Fan: 6 (Zone Follow), Temp: 24C, "
"Zone Follow: On, Sensor Temp: 19C", ac.toString());
// For #Issue2012
EXPECT_EQ(19, ac.getSensorTemp());
EXPECT_EQ(19, ac.toCommon().sensorTemperature);
}

TEST(TestCoolixACClass, SpecialModesAndReset) {
Expand Down Expand Up @@ -1068,3 +1071,36 @@ TEST(TestDecodeCoolix48, SyntheticSelfDecode) {
"m552s5244",
irsend.outputStr());
}

// Test for issue https://github.com/crankyoldgit/IRremoteESP8266/issues/2012#issuecomment-1650098971
TEST(TestCoolixACClass, Issue2012) {
IRrecv irrecv(kGpioUnused);
IRCoolixAC ac(kGpioUnused);

ac.stateReset();
ac.setRaw(0xB21FD8);
EXPECT_EQ(
"Power: On, Mode: 2 (Auto), Fan: 0 (Auto0), Temp: 26C, "
"Zone Follow: Off, Sensor Temp: Off",
ac.toString());
EXPECT_EQ(kNoTempValue, ac.toCommon().sensorTemperature);

ac.setRaw(0xB21F98);
EXPECT_EQ(
"Power: On, Mode: 2 (Auto), Fan: 0 (Auto0), Temp: 27C, "
"Zone Follow: Off, Sensor Temp: Off",
ac.toString());
EXPECT_EQ(kNoTempValue, ac.toCommon().sensorTemperature);

ac.setRaw(0xB21F88);
EXPECT_EQ(
"Power: On, Mode: 2 (Auto), Fan: 0 (Auto0), Temp: 28C, "
"Zone Follow: Off, Sensor Temp: Off",
ac.toString());
EXPECT_EQ(kNoTempValue, ac.toCommon().sensorTemperature);
ac.setRaw(0xB27BE0);
EXPECT_EQ(
"Power: Off",
ac.toString());
EXPECT_EQ(kNoTempValue, ac.toCommon().sensorTemperature);
}

0 comments on commit 2e66680

Please sign in to comment.