IRremoteESP8266 icon indicating copy to clipboard operation
IRremoteESP8266 copied to clipboard

Gree: Fix reporting vertical swing

Open gentoo-root opened this issue 6 months ago • 0 comments

toCommonSwingV() is only called when SwingAuto is false, but it converts kGreeSwingLastPos to kAuto. It doesn't make sense, because:

  1. kGreeSwingLastPos means that swinging is stopped (i.e. the shutter remains in its last position), which corresponds to kOff.
  2. kAuto shouldn't be returned from this function at all, because it's handled separately in toCommon() when SwingAuto is true.
  3. As can be seen in setSwingVertical(), when automatic is false, the valid set of positions includes kGreeSwingLastPos, but not kGreeSwingAuto.

Fix the logic by amending toCommonSwingV() according to the considerations above. It fixes parsing of received IR packets when the user disables vertical swinging from the remote (tested with YAP1FB).

For consistency and robustness, educate setSwingVertical() and convertSwingV() about the supported kGreeSwingLastPos mode.

Add a unit test for the described bug.

gentoo-root avatar Aug 03 '24 00:08 gentoo-root