crankyoldgit / IRremoteESP8266

Infrared remote library for ESP8266/ESP32: send and receive infrared signals with multiple protocols. Based on: https://github.com/shirriff/Arduino-IRremote/
GNU Lesser General Public License v2.1
2.84k stars 810 forks source link

IRHaierAC160 light toggle only working every 2nd time #2081

Open dneuhaeuser opened 3 months ago

dneuhaeuser commented 3 months ago

I am using the IRHaierAC160 implementation with ESPHome and everything is working great so far, except the light toggle switch. currently it only changes the light status every 2nd press.

As is mentioned in the code this light setting is kind of special because it is only controlled by the button code (0x15) in byte 13. But the light button on the remote control works more like a pushbutton than a switch. Each time you press it, it sends the exact same code for switching the light on or off.

But the function setLightToggle sets the button depending on bool value to different codes. https://github.com/crankyoldgit/IRremoteESP8266/blob/61b43dea9726332c11ed6e26f0c4e7c95e9602f7/src/ir_Haier.cpp#L1776 I think this is wrong. It has to set _.Button = kHaierAc160ButtonLight every time.

Because of this the getLightToggle function unfortunately is useless here, because with this protocol there is no way of knowing the current state of the light. https://github.com/crankyoldgit/IRremoteESP8266/blob/61b43dea9726332c11ed6e26f0c4e7c95e9602f7/src/ir_Haier.cpp#L1769