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

Gree: Fix reporting vertical swing #2125

Merged
merged 1 commit into from
Sep 5, 2024
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
4 changes: 3 additions & 1 deletion src/ir_Gree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ void IRGreeAC::setSwingVertical(const bool automatic, const uint8_t position) {
uint8_t new_position = position;
if (!automatic) {
switch (position) {
case kGreeSwingLastPos:
case kGreeSwingUp:
case kGreeSwingMiddleUp:
case kGreeSwingMiddle:
Expand Down Expand Up @@ -503,6 +504,7 @@ uint8_t IRGreeAC::convertFan(const stdAc::fanspeed_t speed) {
/// @return The native equivalent of the enum.
uint8_t IRGreeAC::convertSwingV(const stdAc::swingv_t swingv) {
switch (swingv) {
case stdAc::swingv_t::kOff: return kGreeSwingLastPos;
case stdAc::swingv_t::kHighest: return kGreeSwingUp;
case stdAc::swingv_t::kHigh: return kGreeSwingMiddleUp;
case stdAc::swingv_t::kMiddle: return kGreeSwingMiddle;
Expand Down Expand Up @@ -562,7 +564,7 @@ stdAc::swingv_t IRGreeAC::toCommonSwingV(const uint8_t pos) {
case kGreeSwingMiddle: return stdAc::swingv_t::kMiddle;
case kGreeSwingMiddleDown: return stdAc::swingv_t::kLow;
case kGreeSwingDown: return stdAc::swingv_t::kLowest;
default: return stdAc::swingv_t::kAuto;
default: return stdAc::swingv_t::kOff;
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/ir_Gree_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,11 @@ TEST(TestGreeClass, toCommon) {
ASSERT_FALSE(ac.toCommon().filter);
ASSERT_FALSE(ac.toCommon().beep);
ASSERT_EQ(-1, ac.toCommon().clock);

// Test kGreeSwingLastPos following the pattern in IRac::gree().
ASSERT_EQ(kGreeSwingLastPos, ac.convertSwingV(stdAc::swingv_t::kOff));
ac.setSwingVertical(false, kGreeSwingLastPos);
ASSERT_EQ(stdAc::swingv_t::kOff, ac.toCommon().swingv);
}

TEST(TestGreeClass, Issue814Power) {
Expand Down
Loading