Skip to content

Commit

Permalink
HAIER_AC160: Experimental detail support. (#1852)
Browse files Browse the repository at this point in the history
* This is basically a cut & paste of the `IRHaierAC176` class.
  - Without some features. e.g. SwingH
  - Modified values for SwingV
* Rough unit test coverage for new code.
  - Needs more real data to confirm etc.
* Add in support required for `IRac` class to work with this protocol.
* Add Light support
  - Report the button press code.
  - Make a guess at how the setting works.
    - i.e. The button code toggles the light on and off.
  - Adjust `toCommon()` to handle previous state.
  - Handle the light toggles appropriately.
  - Add a unit test case.
* Add AuxHeating setting.
* Add support for setting/getting Health/Filter status.

Fixes #1804
  • Loading branch information
crankyoldgit authored Aug 17, 2022
1 parent 7a8cf9c commit 48f2db2
Show file tree
Hide file tree
Showing 6 changed files with 1,399 additions and 5 deletions.
77 changes: 77 additions & 0 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ bool IRac::isProtocolSupported(const decode_type_t protocol) {
#if SEND_HAIER_AC
case decode_type_t::HAIER_AC:
#endif
#if SEND_HAIER_AC160
case decode_type_t::HAIER_AC160:
#endif // SEND_HAIER_AC160
#if SEND_HAIER_AC176
case decode_type_t::HAIER_AC176:
#endif // SEND_HAIER_AC176
Expand Down Expand Up @@ -1200,6 +1203,52 @@ void IRac::haier(IRHaierAC *ac,
}
#endif // SEND_HAIER_AC

#if SEND_HAIER_AC160
/// Send a Haier 160 bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRHaierAC160 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] celsius Temperature units. True is Celsius, False is Fahrenheit.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] quiet Run the device in quiet mode.
/// @param[in] filter Turn on the (ion/pollen/etc) filter mode.
/// @param[in] clean Turn on the clean mode.
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] prevlight Previous LED/Display mode.
/// @param[in] sleep Nr. of minutes for sleep mode. -1 is Off, >= 0 is on.
void IRac::haier160(IRHaierAC160 *ac,
const bool on, const stdAc::opmode_t mode,
const bool celsius, const float degrees,
const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv,
const bool turbo, const bool quiet, const bool filter,
const bool clean, const bool light, const bool prevlight,
const int16_t sleep) {
ac->begin();
// No Model setting available.
ac->setMode(ac->convertMode(mode));
ac->setUseFahrenheit(!celsius);
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingV(ac->convertSwingV(swingv));
// No Horizontal Swing setting available.
ac->setQuiet(quiet);
ac->setTurbo(turbo);
ac->setHealth(filter);
ac->setClean(clean);
// No Clean setting available.
// No Beep setting available.
ac->setSleep(sleep >= 0); // Sleep on this A/C is either on or off.
ac->setPower(on);
// Light needs to be sent last as the "button" value seems to control it.
ac->setLightToggle(light ^ prevlight);
ac->send();
}
#endif // SEND_HAIER_AC160

#if SEND_HAIER_AC176
/// Send a Haier 176 bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRHaierAC176 object to use.
Expand Down Expand Up @@ -2764,6 +2813,9 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
const stdAc::swingv_t prev_swingv = (prev != NULL) ? prev->swingv
: stdAc::swingv_t::kOff;
#endif // (SEND_LG || SEND_SHARP_AC)
#if (SEND_HAIER_AC160)
const bool prev_light = (prev != NULL) ? prev->light : !send.light;
#endif // (SEND_HAIER_AC160)
#if SEND_MIDEA
const bool prev_quiet = (prev != NULL) ? prev->quiet : !send.quiet;
#endif // SEND_MIDEA
Expand Down Expand Up @@ -2978,6 +3030,16 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
break;
}
#endif // SEND_HAIER_AC
#if SEND_HAIER_AC160
case HAIER_AC160:
{
IRHaierAC160 ac(_pin, _inverted, _modulation);
haier160(&ac, send.power, send.mode, send.celsius, send.degrees,
send.fanspeed, send.swingv, send.turbo, send.filter, send.clean,
send.light, prev_light, send.sleep);
break;
}
#endif // SEND_HAIER_AC160
#if SEND_HAIER_AC176
case HAIER_AC176:
{
Expand Down Expand Up @@ -3876,6 +3938,13 @@ namespace IRAcUtils {
return ac.toString();
}
#endif // DECODE_HAIER_AC
#if DECODE_HAIER_AC160
case decode_type_t::HAIER_AC160: {
IRHaierAC160 ac(kGpioUnused);
ac.setRaw(result->state);
return ac.toString();
}
#endif // DECODE_HAIER_AC160
#if DECODE_HAIER_AC176
case decode_type_t::HAIER_AC176: {
IRHaierAC176 ac(kGpioUnused);
Expand Down Expand Up @@ -4351,6 +4420,14 @@ namespace IRAcUtils {
break;
}
#endif // DECODE_HAIER_AC
#if DECODE_HAIER_AC160
case decode_type_t::HAIER_AC160: {
IRHaierAC160 ac(kGpioUnused);
ac.setRaw(decode->state);
*result = ac.toCommon(prev);
break;
}
#endif // DECODE_HAIER_AC160
#if DECODE_HAIER_AC176
case decode_type_t::HAIER_AC176: {
IRHaierAC176 ac(kGpioUnused);
Expand Down
9 changes: 9 additions & 0 deletions src/IRac.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ void electra(IRElectraAc *ac,
const bool filter, const int16_t sleep = -1,
const int16_t clock = -1);
#endif // SEND_HAIER_AC
#if SEND_HAIER_AC160
void haier160(IRHaierAC160 *ac,
const bool on, const stdAc::opmode_t mode, const bool celsius,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv,
const bool turbo, const bool quiet, const bool filter,
const bool clean, const bool light, const bool prevlight,
const int16_t sleep = -1);
#endif // SEND_HAIER_AC160
#if SEND_HAIER_AC176
void haier176(IRHaierAC176 *ac,
const haier_ac176_remote_model_t model, const bool on,
Expand Down
Loading

0 comments on commit 48f2db2

Please sign in to comment.