IRremoteESP8266
IRremoteESP8266 copied to clipboard
Gree: Fix reporting vertical swing
toCommonSwingV() is only called when SwingAuto is false, but it converts kGreeSwingLastPos to kAuto. It doesn't make sense, because:
- kGreeSwingLastPos means that swinging is stopped (i.e. the shutter remains in its last position), which corresponds to kOff.
- kAuto shouldn't be returned from this function at all, because it's handled separately in toCommon() when SwingAuto is true.
- 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.