ESPHome Remote Receiver question

Hello, I am trying to replicate the signals from my remote to control the air conditioning.
This is an air conditioner and is not in the list of supported devices. For now I just want to be able to turn the machine on and off. Shipping would not be a problem. I would like to be able to update the status when receiving the signal from the remote control using remote receiver automations.

# Example automation for decoded signals
remote_receiver:
  ...
  on_samsung:
    then:
    - if:
        condition:
          or:
            - lambda: 'return (x.data == 0xE0E0E01F);'  # VOL+ newer type
            - lambda: 'return (x.data == 0xE0E0E01F0);' # VOL+ older type
        then:
          - ...

This is the example given, but I would like to use it for haier since the codes can be recognized.
I have tried:

remote_receiver:
  id: rcvr
  pin: 
    number: GPIO2
    inverted: true
  dump: raw
  on_haier:
    then:
    - if:
        condition:
          or:
            - lambda: 'return (x.data == A6.EC.0F.00.79.40.00.20.00.00.00.00.05);'
        then:
          - switch.turn_on: ac2

But it gives a compilation error.
Does anyone have an idea? Can you help me?

Well, seeing that those compilation errors tell you what is causing the error, its usually a good idea to go ahead and copy that too.

If you only have 1 condition under an -if statement, you can delete the ‘or’ since theres not multiple conditions.

Yes true, or was a copy paste, but I don’t really use it, it comes from the example.
The error given is:

<unicode string>: In lambda function:
<unicode string>:39:25: error: 'A6' was not declared in this scope; did you mean 'A0'?
<unicode string>:39:30: error: expected ')' before numeric constant
*** [.pioenvs/aire-acondicionado-2/src/main.cpp.o] Error 1

and this code is just like the one I received:

Received Haier: A6.EC.0F.00.79.40.00.20.00.00.00.00.05 (13)

My C++ isnt the best but, if you look at the error it doesnt like tne syntax for the raw code. I think its because its starting with a letter and not a number.

Another way to do the same thing is just make a binary sensor.
‘’’
binary_sensor:

  • platform: remote_receiver
    name: “Haier Remote Input”
    Haier:

    command: A6.EC.0F.00.79.40.00.20.00.00.00.00.05
    on_click:
    min_length: 50ms
    max_length: 350ms
    then:
    - switch.turn_on: ac2
    ‘’’

I was completely unaware of the ‘remote_receiver’ platform of a ‘binary_sensor’. I have searched for information and how to configure it because it gave me a compilation error.

binary_sensor:
  - platform: remote_receiver
    name: "Haier Remote Input"
    haier: 
      code: [0xA6, 0x72, 0x00, 0x00, 0x61, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x05]
    on_press:
      then:
        - switch.toggle: ac2
src/main.cpp: In function 'void setup()':
src/main.cpp:238:34: error: 'using HaierBinarySensor = class esphome::remote_base::RemoteReceiverBinarySensor<esphome::remote_base::HaierProtocol>' {aka 'class esphome::remote_base::RemoteReceiverBinarySensor<esphome::remote_base::HaierProtocol>'} has no member named 'set_code'
  238 |   remote_base_haierbinarysensor->set_code({0xA6, 0x72, 0x00, 0x00, 0x61, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x05});
      |                                  ^~~~~~~~
*** [.pioenvs/aire-acondicionado-2/src/main.cpp.o] Error 1

In the end I chose to use RAW commands, but of course now I have another problem. Every time I press the button a few seconds apart, the command changes slightly.

[19:26:52][I][remote.haier:080]: Received Haier: A6.EC.00.00.31.40.00.20.00.00.00.00.05 (13)
[19:26:57][I][remote.haier:080]: Received Haier: A6.EC.00.00.72.40.00.20.00.00.00.00.05 (13)
[19:27:15][I][remote.haier:080]: Received Haier: A6.EC.00.00.32.40.00.20.00.00.00.00.05 (13)
[19:27:17][I][remote.haier:080]: Received Haier: A6.EC.00.00.72.40.00.20.00.00.00.00.05 (13)
[19:27:33][I][remote.haier:080]: Received Haier: A6.EC.00.00.32.40.00.20.00.00.00.00.05 (13)
[19:27:46][I][remote.haier:080]: Received Haier: A6.EC.00.00.72.40.00.20.00.00.00.00.05 (13)
[19:27:53][I][remote.haier:080]: Received Haier: A6.EC.00.00.33.40.00.20.00.00.00.00.05 (13)
[19:28:10][I][remote.haier:080]: Received Haier: A6.EC.00.00.73.40.00.20.00.00.00.00.05 (13)
[19:28:10][I][remote.haier:080]: Received Haier: A6.EC.00.00.33.40.00.20.00.00.00.00.05 (13)
[19:28:15][I][remote.haier:080]: Received Haier: A6.EC.00.00.73.40.00.20.00.00.00.00.05 (13)
[19:28:17][I][remote.haier:080]: Received Haier: A6.EC.00.00.33.40.00.20.00.00.00.00.05 (13)

This short list is equivalent to pressing the single on/off button. It is clearly noticeable when it is turned on and when it is turned off. I’m blocked right now.

Any ideas?

Oh… That, im not sure about. Those are all from single presses of the same button?

Not a single press, several, but always the same button, on/off.

Or maybe I have something wrong in the code:

remote_receiver:
  id: rcvr
  pin: 
    number: GPIO2
    inverted: true
  dump: haier

At first the manufacturer did not detect me, until I set inverted: true.