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?