Skip to content

Commit 48f2db2

Browse files
authored
HAIER_AC160: Experimental detail support. (#1852)
* 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
1 parent 7a8cf9c commit 48f2db2

File tree

6 files changed

+1399
-5
lines changed

6 files changed

+1399
-5
lines changed

src/IRac.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ bool IRac::isProtocolSupported(const decode_type_t protocol) {
219219
#if SEND_HAIER_AC
220220
case decode_type_t::HAIER_AC:
221221
#endif
222+
#if SEND_HAIER_AC160
223+
case decode_type_t::HAIER_AC160:
224+
#endif // SEND_HAIER_AC160
222225
#if SEND_HAIER_AC176
223226
case decode_type_t::HAIER_AC176:
224227
#endif // SEND_HAIER_AC176
@@ -1200,6 +1203,52 @@ void IRac::haier(IRHaierAC *ac,
12001203
}
12011204
#endif // SEND_HAIER_AC
12021205

1206+
#if SEND_HAIER_AC160
1207+
/// Send a Haier 160 bit A/C message with the supplied settings.
1208+
/// @param[in, out] ac A Ptr to an IRHaierAC160 object to use.
1209+
/// @param[in] on The power setting.
1210+
/// @param[in] mode The operation mode setting.
1211+
/// @param[in] celsius Temperature units. True is Celsius, False is Fahrenheit.
1212+
/// @param[in] degrees The temperature setting in degrees.
1213+
/// @param[in] fan The speed setting for the fan.
1214+
/// @param[in] swingv The vertical swing setting.
1215+
/// @param[in] turbo Run the device in turbo/powerful mode.
1216+
/// @param[in] quiet Run the device in quiet mode.
1217+
/// @param[in] filter Turn on the (ion/pollen/etc) filter mode.
1218+
/// @param[in] clean Turn on the clean mode.
1219+
/// @param[in] light Turn on the LED/Display mode.
1220+
/// @param[in] prevlight Previous LED/Display mode.
1221+
/// @param[in] sleep Nr. of minutes for sleep mode. -1 is Off, >= 0 is on.
1222+
void IRac::haier160(IRHaierAC160 *ac,
1223+
const bool on, const stdAc::opmode_t mode,
1224+
const bool celsius, const float degrees,
1225+
const stdAc::fanspeed_t fan,
1226+
const stdAc::swingv_t swingv,
1227+
const bool turbo, const bool quiet, const bool filter,
1228+
const bool clean, const bool light, const bool prevlight,
1229+
const int16_t sleep) {
1230+
ac->begin();
1231+
// No Model setting available.
1232+
ac->setMode(ac->convertMode(mode));
1233+
ac->setUseFahrenheit(!celsius);
1234+
ac->setTemp(degrees);
1235+
ac->setFan(ac->convertFan(fan));
1236+
ac->setSwingV(ac->convertSwingV(swingv));
1237+
// No Horizontal Swing setting available.
1238+
ac->setQuiet(quiet);
1239+
ac->setTurbo(turbo);
1240+
ac->setHealth(filter);
1241+
ac->setClean(clean);
1242+
// No Clean setting available.
1243+
// No Beep setting available.
1244+
ac->setSleep(sleep >= 0); // Sleep on this A/C is either on or off.
1245+
ac->setPower(on);
1246+
// Light needs to be sent last as the "button" value seems to control it.
1247+
ac->setLightToggle(light ^ prevlight);
1248+
ac->send();
1249+
}
1250+
#endif // SEND_HAIER_AC160
1251+
12031252
#if SEND_HAIER_AC176
12041253
/// Send a Haier 176 bit A/C message with the supplied settings.
12051254
/// @param[in, out] ac A Ptr to an IRHaierAC176 object to use.
@@ -2764,6 +2813,9 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
27642813
const stdAc::swingv_t prev_swingv = (prev != NULL) ? prev->swingv
27652814
: stdAc::swingv_t::kOff;
27662815
#endif // (SEND_LG || SEND_SHARP_AC)
2816+
#if (SEND_HAIER_AC160)
2817+
const bool prev_light = (prev != NULL) ? prev->light : !send.light;
2818+
#endif // (SEND_HAIER_AC160)
27672819
#if SEND_MIDEA
27682820
const bool prev_quiet = (prev != NULL) ? prev->quiet : !send.quiet;
27692821
#endif // SEND_MIDEA
@@ -2978,6 +3030,16 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
29783030
break;
29793031
}
29803032
#endif // SEND_HAIER_AC
3033+
#if SEND_HAIER_AC160
3034+
case HAIER_AC160:
3035+
{
3036+
IRHaierAC160 ac(_pin, _inverted, _modulation);
3037+
haier160(&ac, send.power, send.mode, send.celsius, send.degrees,
3038+
send.fanspeed, send.swingv, send.turbo, send.filter, send.clean,
3039+
send.light, prev_light, send.sleep);
3040+
break;
3041+
}
3042+
#endif // SEND_HAIER_AC160
29813043
#if SEND_HAIER_AC176
29823044
case HAIER_AC176:
29833045
{
@@ -3876,6 +3938,13 @@ namespace IRAcUtils {
38763938
return ac.toString();
38773939
}
38783940
#endif // DECODE_HAIER_AC
3941+
#if DECODE_HAIER_AC160
3942+
case decode_type_t::HAIER_AC160: {
3943+
IRHaierAC160 ac(kGpioUnused);
3944+
ac.setRaw(result->state);
3945+
return ac.toString();
3946+
}
3947+
#endif // DECODE_HAIER_AC160
38793948
#if DECODE_HAIER_AC176
38803949
case decode_type_t::HAIER_AC176: {
38813950
IRHaierAC176 ac(kGpioUnused);
@@ -4351,6 +4420,14 @@ namespace IRAcUtils {
43514420
break;
43524421
}
43534422
#endif // DECODE_HAIER_AC
4423+
#if DECODE_HAIER_AC160
4424+
case decode_type_t::HAIER_AC160: {
4425+
IRHaierAC160 ac(kGpioUnused);
4426+
ac.setRaw(decode->state);
4427+
*result = ac.toCommon(prev);
4428+
break;
4429+
}
4430+
#endif // DECODE_HAIER_AC160
43544431
#if DECODE_HAIER_AC176
43554432
case decode_type_t::HAIER_AC176: {
43564433
IRHaierAC176 ac(kGpioUnused);

src/IRac.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ void electra(IRElectraAc *ac,
275275
const bool filter, const int16_t sleep = -1,
276276
const int16_t clock = -1);
277277
#endif // SEND_HAIER_AC
278+
#if SEND_HAIER_AC160
279+
void haier160(IRHaierAC160 *ac,
280+
const bool on, const stdAc::opmode_t mode, const bool celsius,
281+
const float degrees, const stdAc::fanspeed_t fan,
282+
const stdAc::swingv_t swingv,
283+
const bool turbo, const bool quiet, const bool filter,
284+
const bool clean, const bool light, const bool prevlight,
285+
const int16_t sleep = -1);
286+
#endif // SEND_HAIER_AC160
278287
#if SEND_HAIER_AC176
279288
void haier176(IRHaierAC176 *ac,
280289
const haier_ac176_remote_model_t model, const bool on,

0 commit comments

Comments
 (0)