Skip to content

Commit

Permalink
Kelon: Add utility method to ensure power on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
depau committed Jun 11, 2021
1 parent 1fc4e17 commit 7838ff6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/ir_Kelon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,33 @@ void IRKelonAC::send(const uint16_t repeat) {
_.TimerHalfHour = 0;
}

/// Ensures the AC is on or off by exploiting the fact that setting
/// it to "smart" will always turn it on if it's off.
/// This method will send 2 commands to ensure the AC is on, 3 to
/// ensure it is off.
/// @param[in] on Whether to ensure the AC is on or off
void IRKelonAC::ensurePower(bool on) {
// Try to avoid turning on the compressor for this operation.
// "Dry grade", when in "smart" mode, acts as a temperature offset that
// the user can configure if they feel too cold or too hot. By setting it
// to +2 we're setting the temperature to ~28°C, which will effectively
// set the AC to fan mode.
int8_t previousDry = getDryGrade();
setDryGrade(2);
setMode(kKelonModeSmart);
send();

setDryGrade(previousDry);
setMode(_previousMode);
send();

// Now we're sure it's on. Turn it back off.
if (!on) {
setTogglePower(true);
send();
}
}

#endif // SEND_KELON

/// Set up hardware to be able to send a message.
Expand Down
6 changes: 6 additions & 0 deletions src/ir_Kelon.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class IRKelonAC {
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate() { return _irsend.calibrate(); }

/// Since the AC does not support actually setting the power state to a known
/// value, this utility allow ensuring the AC is on or off by exploiting
/// the fact that the AC, according to the user manual, will always turn on
/// when setting it to "smart" or "super" mode.
void ensurePower(bool on);

#endif


Expand Down

0 comments on commit 7838ff6

Please sign in to comment.