ESP8266 TX IR command issue

I will start saying that I am not an expert.

I have been successfully using broadlink to control my AC with SmartIR with a json code file that I generated myself for long.

My broadlink finally failed and I decided to replace it with a ESP-12F module (esp8266 based) with RX/TX IR to possibly integrate it inside the AC.

I successfully flashed ESPHome (see configuration below).

esphome:
  name: irtxcucina
  friendly_name: IRTX Cucina

esp8266:
  board: esp12e

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: "Key"
  reboot_timeout: 0s  # Optional: Prevent unexpected reboots

  # services:
    # - service: send_chunked_command
      # variables:
        # commands: int[]
      # then:
        # - repeat:
            # count: !lambda 'return (commands.size() + 99) / 100;'  # Calculate number of chunks
            # then:
              # - remote_transmitter.transmit_raw:
                  # code: !lambda |-
                    # int start = iteration * 100;
                    # int end = std::min(start + 100, static_cast<int>(commands.size()));
                    # std::vector<int> chunk(commands.begin() + start, commands.begin() + end);
                    # return chunk;

  services:
   - service: send_raw_command
     variables:
       command: int[]
     then:
       - remote_transmitter.transmit_raw:
           code: !lambda 'return command;'

ota:
  - platform: esphome
    password: "psw"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "Ir-Rx-Tx-Condizionatore-Cucina"
    password: "psw"

captive_portal:

remote_transmitter:
  pin: GPIO4  # Pin GPIO collegato al LED IR
  carrier_duty_percent: 50%

# (Opzionale) Ricevitore IR per acquisire codici IR
remote_receiver:
  pin:
    number: GPIO14
    inverted: true
  dump: all
  idle: 25ms

# Configurazione LED di stato (opzionale)
status_led:
  pin: GPIO2  # Collegamento opzionale per indicare lo stato del dispositivo

I then converted Base64 commands to Raw as needed by the esp8266 using:

python3 -m irgen -i broadlink_base64 -d string -o raw > raw_code.txt

python3 -m irgen -i broadlink_base64 -d JgA2AXA1Dw0PDBAMDwwPDRAMDygPDBAMEAwPDA8NDwwQDBAMDwwPDQ8MECcQDA8oEAwPDQ8MDw0PDBAMDwwQDBAMDwwPKBAMECcQJxAnEQsQJxAnEAwPKBAMDw0PDA8NDwwQJxAMDw0PKBAnEAwPDBAnEAwPDBAoDwwQJxAMDw0PKA8oECcPKBAnEAwPDQ8MEAwQDA8MDw0PDBAMDw0PDBAnECcQDA8NDwwQJxAnEQsQDA8oDw0PDBAnECcQDA8oECcQKA8MDygQJxAMDw0PDBAMDw0PDA8oEAwQDA8MDw0PDBAMDwwQDBAMDwwPDQ8MEAwQDA8MDw0PDBAMDw0PDBAMDwwPDQ8MEAwQDA8MDw0QCxAMDw0PDBAMEAsQDA8NDwwQDA8MECgPKA8oDw0PDBAnECcQDA8ADQUAAA== -o > raw_code.txt

Raw converted commands are very long.

I then tested the command using the relevant Service in home assistant.

service: esphome.irtxcucina_send_raw_command
data: {
  "command": [3411, -1614, 457, -396, 457, -365, 487, -365, 457, -365, 457, -396, 487, -365, 457, -1218, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -1188, 487, -365, 457, -1218, 487, -365, 457, -396, 457, -365, 457, -396, 457, -365, 487, -365, 457, -365, 487, -365, 487, -365, 457, -365, 457, -1218, 487, -365, 487, -1188, 487, -1188, 487, -1188, 518, -335, 487, -1188, 487, -1188, 487, -365, 457, -1218, 487, -365, 457, -396, 457, -365, 457, -396, 457, -365, 487, -1188, 487, -365, 457, -396, 457, -1218, 487, -1188, 487, -365, 457, -365, 487, -1188, 487, -365, 457, -365, 487, -1218, 457, -365, 487, -1188, 487, -365, 457, -396, 457, -1218, 457, -1218, 487, -1188, 457, -1218, 487, -1188, 487, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 457, -396, 457, -365, 487, -1188, 487, -1188, 487, -365, 457, -396, 457, -365, 487, -1188, 487, -1188, 518, -335, 487, -365, 457, -1218, 457, -396, 457, -365, 487, -1188, 487, -1188, 487, -365, 457, -1218, 487, -1188, 487, -1218, 457, -365, 457, -1218, 487, -1188, 487, -365, 457, -396, 457, -365, 487, -365, 457, -396, 457, -365, 457, -1218, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 457, -396, 457, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 487, -335, 487, -365, 457, -396, 457, -365, 487, -365, 487, -335, 487, -365, 457, -396, 457, -365, 487, -365, 457, -365, 487, -1218, 457, -1218, 457, -1218, 457, -396, 457, -365, 487, -1188, 487, -1188, 487, -365, 457, -101502]
}

The command is successfully sent to the ESPHome device but it does not work as expected.
I get the following error on the ESPHome device log:

[23:32:33][D][remote_transmitter:075]: Sending remote code...
[23:32:33][W][component:237]: Component api took a long time for an operation (275 ms).
[23:32:33][W][component:238]: Components should block for at most 30 ms.

I don’t get the error message if I pass a shorter code.
I also tried to chunk the command in smaller parts as advised by AI, but it did not work. Do you have any ideas how to fix this?

I wouldn’t worry too much about the error it is common to get in ESPHome and doesn’t necessarily mean there is an error.

The raw commands look excessively long for a simple AC command, I’d suspect your conversion hasn’t worked correctly.

Do you not have the original remote you could capture the codes directly on the ESPHome device? You may find they are something simple like NEC codes. They should appear in the logs as you have dump all on the IR receiver.

Thanks for your reply. I just tried to capture the “off” command as an example, but I have hard times rebuilding the code:

[11:01:28][I][remote.pronto:231]: Received Pronto: data=
[11:01:28][I][remote.pronto:233]: 0000 006D 009A 0000 0082 003F 0013 000E 0012 000E 0011 000F 0011 000F 0011 000F 0011 000F 0011 0030 0011 000F 0011 000F 0011 0010 0011 0010 0011 0010 0011 000F 0011 000F 0011 0010 0011 000F 0011 000F 0011 0010 0011 0030 0011 000F 
[11:01:28][I][remote.pronto:233]: 0011 0030 0011 0010 0011 000F 0011 0010 0011 000F 0011 000F 0011 0010 0011 000F 0011 0010 0011 0010 0011 000F 0011 0030 0011 000F 0011 0030 0011 0030 0011 0030 0011 000F 0011 0030 0011 0030 0011 000F 0011 0030 0011 0010 0011 0010 
[11:01:28][I][remote.pronto:233]: 0011 0030 0011 000F 0011 0010 0011 0030 0011 000F 0011 000F 0011 0030 0011 0010 0011 000F 0011 0010 0011 0030 0011 0010 0011 000F 0011 0030 0011 0010 0011 0010 0011 0030 0011 000F 0011 0030 0011 0030 0011 0030 0011 0030 0011 0030 
[11:01:28][I][remote.pronto:233]: 0011 0010 0011 0010 0011 000F 0011 0010 0011 0010 0011 000F 0011 000F 0011 0010 0011 0010 0011 0010 0011 000F 0011 0010 0011 0030 0011 0010 0010 0031 0010 0010 0010 0030 0011 0031 0010 0031 0010 0031 0010 0011 0010 0010 0010 0031 
[11:01:28][I][remote.pronto:233]: 0010 0031 0010 0011 0010 0011 0010 0031 0010 0031 0010 0011 0010 0010 0010 0031 0010 0031 0010 0011 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 
[11:01:28][I][remote.pronto:233]: 0010 0010 0010 0010 0010 0011 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 0010 0010 0010 0011 0010 0011 0010 0010 
[11:01:28][I][remote.pronto:233]: 0010 0011 0010 0010 0010 0010 0010 0011 0010 0010 0010 0011 0010 0010 0010 0010 0010 0011 0010 0031 0010 0010 0010 0031 0010 0011 0010 0010 0010 0031 0010 0031 0010 0011 0010 03C2 
[11:01:28][I][remote.panasonic:070]: Received Panasonic: address=0x0200, command=0x28017692
[11:01:28][I][remote.aeha:098]: Received AEHA: address=0x0200, data=[0x28,0x01,0x76,0x92,0x44,0x97,0xC0,0x02,0xBC,0xCC,0xC0,0x00,0x00,0x00,0x00,0x00,0xA6]
[11:01:28][W][component:237]: Component remote_receiver took a long time for an operation (181 ms).
[11:01:28][W][component:238]: Components should block for at most 30 ms.

Can somebody help me out in rebuilding the correct code
thanks

What make/model AC you have?

They can be long, mine is 288 bits, so 576 raw values.

Your receiver has guessed two protocols AEHA and Panasonic if it was me I would press more buttons see if one of those two stands out as being consistently received for every button. If you find the correct protocol sending them is much easier than trying to decode and send raw protocols, you could try with the following code which will create two buttons for you.

button:
  - platform: template
    name: "Test1AEHA"
    id: test1
    on_press:
      - remote_transmitter.transmit_aeha:
          address: 0x0200
          data: [0x28,0x01,0x76,0x92,0x44,0x97,0xC0,0x02,0xBC,0xCC,0xC0,0x00,0x00,0x00,0x00,0x00,0xA6]
   - platform: template
     name: "Test2Panasonic"
     id: test2
     on_press:
       - remote_transmitter.transmit_panasonic:
           address: 0x0200
           command: 0x28017692

Make of AC will help as well.

I am not an expert, but this looks a very promising approach.
Make: Sanyo
Model: SAP-KRV96EHDS
I understand that very likely this unit was made by Panasonic.
I will try with the two buttons and report the outcome. Thanks!

There are many different protocols for both, Sanyo and Panasonic.
Sanyo for example have 72bit, 88bit and 152bit protocols.

To possibly decode yours, and at least to get some usable data out of it, I warmly recommend to try with this arduino library first. When you know what you are playing with, it’s easier to adapt it for esphome.

Edit:

This code is valid Sanyo 152bit code. Header (3400, -1700) plus 152 data signals

I tried these two buttons, but apparently nothing happens. ESP transmits the code but the AC does not react.

Thank you for your input. I am afraid this is beyond my capability. I would not know how to use an Arduino library on my esp8266 device. I am using ESPHome for its simplicity. I was hoping it was a matter to capture all the codes and use them in json file like it is done with smartIR. It is a bit hard for me detecing and working on protocols.

Actually your captured raw signal looks good enough to be transmitted.

 on_press:
      - remote_transmitter.transmit_raw:
          code: [3411, -1614, 457, -396, 457, -365, 487, -365, 457, -365, 457, -396, 487, -365, 457, -1218, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -1188, 487, -365, 457, -1218, 487, -365, 457, -396, 457, -365, 457, -396, 457, -365, 487, -365, 457, -365, 487, -365, 487, -365, 457, -365, 457, -1218, 487, -365, 487, -1188, 487, -1188, 487, -1188, 518, -335, 487, -1188, 487, -1188, 487, -365, 457, -1218, 487, -365, 457, -396, 457, -365, 457, -396, 457, -365, 487, -1188, 487, -365, 457, -396, 457, -1218, 487, -1188, 487, -365, 457, -365, 487, -1188, 487, -365, 457, -365, 487, -1218, 457, -365, 487, -1188, 487, -365, 457, -396, 457, -1218, 457, -1218, 487, -1188, 457, -1218, 487, -1188, 487, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 457, -396, 457, -365, 487, -1188, 487, -1188, 487, -365, 457, -396, 457, -365, 487, -1188, 487, -1188, 518, -335, 487, -365, 457, -1218, 457, -396, 457, -365, 487, -1188, 487, -1188, 487, -365, 457, -1218, 487, -1188, 487, -1218, 457, -365, 457, -1218, 487, -1188, 487, -365, 457, -396, 457, -365, 487, -365, 457, -396, 457, -365, 457, -1218, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 457, -396, 457, -365, 487, -365, 457, -365, 457, -396, 457, -365, 487, -365, 487, -365, 457, -365, 457, -396, 487, -335, 487, -365, 457, -396, 457, -365, 487, -365, 487, -335, 487, -365, 457, -396, 457, -365, 487, -365, 457, -365, 487, -1218, 457, -1218, 457, -1218, 457, -396, 457, -365, 487, -1188, 487, -1188, 487, -365, 457, -101502]

You might need to send it twice with repeat option.
Also your TX range might be only moderate, place it close to the AC.
Verify through your phone camera that emitter is working.