Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAIER_AC160: Experimental detail support. #1852

Merged
merged 5 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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