Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tamI have an LG portable air conditioner with an IR remote. I also have a small IR transmitter receiver board with a bk7231 processor, running openbk. It can detect the IR remote but the codes in the debug log don't make a lot of sense. How do I find the codes for the AC, either online or by receiving them from the remote, And what are the steps to transmit them again? In any sort of script, or ideally from HA via mqtt.
• Capture the full 28-/32-bit “LG” (or “LG2”) codes with the IR-receiver in OpenBK; each key press transmits the complete AC state.
• If OpenBK shows JSON such as
IRRecv: {"protocol":"LG","bits":28,"data":0x88C0051}
—save that value; if it only dumps timings, upgrade OpenBK or use IRSendRaw
later.
• Wire an IR LED (with transistor driver) to a GPIO defined as IR_Send
, then send the stored code with
IRSend LG 0x88C0051 28
or via MQTT: topic cmnd/<device>/IRSend
, payload LG 0x88C0051 28
.
• Create HA MQTT scripts/buttons (or an MQTT-climate) that publish those payloads; OpenBK executes them and the AC reacts.
• Online repositories such as github.com/crankyoldgit/IRremoteESP8266 ( ir_LG.cpp
) or IRDB already contain many LG-AC codes if you prefer not to learn them yourself.
LG AC IR protocol
• Most portables use the LG 28-bit (older) or LG2 32-bit frame.
• Timing: 8.4 ms mark + 4.2 ms space header, then 0.56 ms mark; logical “0” = 0.56 ms space, logical “1” = 1.69 ms space, 38 kHz carrier.
• Every frame carries: Power, Mode, Target Temp, Fan, Swing, Timer, plus a checksum → a new code for every unique state.
Setting up OpenBK to capture
a. Hardware
– IR receiver (e.g. VS1838/TSPD1) → 3.3 V, GND, data to free GPIO (e.g. P10).
b. Firmware
startDriver IRRecv
(or enable in Web → Drivers).
Module Config → assign GPIO = IR_Recv
.
c. Logging
View “Log” tab or subscribe to tele/<device>/IR
(if MQTT_IR
is enabled).
Typical decoded line:
IR: {"protocol":"LG","bits":28,"data":0x88C0152}
d. If only raw timings appear (+9000 -4500 …
)
– Upgrade to the newest nightly build (LG decode fixes merged Sep-2023).
– Else copy the whole array and keep for IRSendRaw
.
Mapping useful states
Because the code is stateful, decide which combinations you really need (e.g. OFF, COOL 22 Auto, COOL 24 Low). Capture once for each—don’t try to press Temp-Up/Down sequentially.
Where to find codes online (when capture impossible)
• IRremoteESP8266 → examples/IRrecvDumpV2
output in ir_LG.cpp
lists dozens of frames.
• GitHub mad-ady/lg-ac-remote-lirc
supplies LIRC files (hex or Pronto).
• IRDB (probonopd/irdb
) → folder air_conditioner/lg
.
Convert Pronto to hex with irtool.py -p pronto -r
.
Transmitting with OpenBK
a. Transmitter wiring
GPIO → 1 kΩ → NPN base, collector → LED + resistor (100 Ω) → 3.3 V.
Assign GPIO as IR_Send
; startDriver IRSend
.
b. CLI test
IRSend LG 0x88C0152 28
c. Raw fallback
IRSendRaw 9000,4500,560,560,560,1690,…
d. MQTT
Publish: cmnd/bedroom_ac/IRSend
payload LG 0x88C0152 28
.
OpenBK executes any command topic in the form cmnd/<dev>/<command>
automatically.
Home-Assistant integration
Option A – simple buttons/scripts
mqtt:
button:
- name: "AC Power OFF"
command_topic: "cmnd/bedroom_ac/IRSend"
payload_press: "LG 0x88C03FC 28"
Option B – full MQTT Climate (state-less)
climate:
- platform: mqtt
name: "Bedroom AC"
modes: ["off","cool"]
mode_command_topic: "cmnd/bedroom_ac/IRSend"
mode_command_template: >
{% if value == 'off' %}LG 0x88C03FC 28{% else %}LG 0x88C0152 28{% endif %}
temperature_command_topic: "cmnd/bedroom_ac/IRSend"
temperature_command_template: >
{% set codes = {20:'0x88C0912',21:'0x88C0812',22:'0x88C0152',23:'0x88C0052',24:'0x88C0952'} %}
LG {{ codes[value|int] }} 28
temp_step: 1
(No feedback from the AC unless you add an external temperature probe.)
• Recent OpenBK nightlies (Jan-2024+) added IRHVAC
helper similar to Tasmota; work is ongoing to let the firmware build LG frames on-the-fly, eliminating huge lookup tables.
• Matter-over-MQTT bridges are being prototyped; once OpenBK supports Matter, the same IR backend will work without additional HA YAML.
• Commercial IR blasters (SwitchBot, Broadlink) increasingly publish their code sets openly; these dumps are feeding IRDB and Flipper-IRDB.
• Why a transistor driver? The BK7231 can source only ~6 mA; a good IR LED needs 50–100 mA peak for >5 m range.
• Why does “Temp Up” twice give a different code than one step? Because the temperature nibble in the frame is absolute (e.g., 22 °C = 0x16).
• Checksum: last 4 bits are usually inverted XOR of previous bytes. When you simply replay a learned frame, checksum is already valid.
• Replaying IR intended for your own appliance is allowed in most jurisdictions.
• Avoid broadcasting high-power IR indiscriminately—medical devices and neighbours’ equipment could be affected.
• Do not distribute copyrighted LG firmware extracts; only share user-generated code dumps.
• Store learned frames in OpenBK’s on-device flash (addKeyValue AC_COOL_22 "LG 0x88C0152 28"
).
• Use Rules
to map MQTT payloads to those key-values to keep HA YAML small.
• Test from <1 m first, then increase distance; adjust resistor or use two IR LEDs if range is poor.
• Back-up your autoexec.bat
and rules via the WebFS page.
• Portable LG units sometimes switch to a different 56-bit protocol (LGHM) introduced in 2022; if you always get “Unknown: 56 bits” consider building/using the IRremoteESP8266 dev branch that already supports LGHM.
• OpenBK IR drivers are still evolving; future firmware may rename IRSendRaw
to IRSNDRAW
. Check release notes.
• Experiment with the open-source LG HVAC
class in IRremoteESP8266 to generate frames dynamically (you can port the small C++ routine into an OpenBK script).
• Monitor upcoming OpenBK pull-requests for “IRHVAC generic driver”.
• Consider adding a BLE temperature sensor; HA can then automate target codes based on ambient temp.
• Resources:
– https://github.com/crankyoldgit/IRremoteESP8266
– https://github.com/probonopd/irdb
– OpenBK Wiki: IR section (updated weekly)
Capture each desired LG-AC state with the OpenBK IR receiver (or copy it from IRDB), store the 28/32-bit hex value, and replay it with IRSend
from either the OpenBK console or via MQTT. Wire the IR LED correctly, verify with the phone-camera test, then create HA MQTT buttons or an MQTT-climate entity. Because LG remotes are fully state-based, keep a library of frames or migrate to forthcoming OpenBK “IRHVAC” code-generation to scale beyond a handful of commands.