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.
• LG AC remotes transmit a long “state-frame” (not a simple button code), so you must either
a) capture every frame you need from the original remote, or
b) decode the frame structure and generate it on-the-fly.
• OpenBeken (OpenBK) can do both: it logs each received frame and can replay it with the IRSend
command (console, HTTP or MQTT).
• Workflow:
1. Assign the GPIOs to IRRecv
and IRSend
, start the driver.
2. Press the remote and copy the JSON line (or the raw mark/space array).
3. Verify the frame by replaying it: IRSend {"Protocol":"LG","Bits":48,"Data":"0x88xxxx…"}
(or "Protocol":"RAW"
with RawData
).
4. Store each verified frame in an OpenBK script or expose an MQTT topic (e.g. cmnd/lg_ac/IRSend
).
5. In Home-Assistant create scripts, automations or a template MQTT-Climate entity that publishes the JSON payload to that topic.
Key points
– Use OpenBK ≥1.18.x for improved IR logging (IrDbg 1
).
– Most LG portable ACs use 38 kHz carrier, 48 or 56 bits, LSB-first, last byte = checksum.
– If the protocol is not auto-decoded you can still replay the raw timing array.
– MQTT: topic = cmnd/<deviceName>/IRSend
, payload = same JSON you tested in the console.
– Online databases (LIRC, Tasmota/IRremoteESP8266) exist, but model-to-model variation is large—capturing your own remote is usually required.
Why LG codes “make no sense”
• Unlike TV remotes (NEC, RC5), most AC remotes send the complete desired state every time.
• A single bit error (checksum) → AC ignores the frame.
• OpenBK will print a long value (e.g. 0x8800A11405FB
) or a raw array because it cannot map every LG variant to a named command.
Hardware prerequisites
• BK7231 board with IR receiver diode (TSOP-1738 or similar) tied to a 3V3 GPIO.
• IR LED driven via a transistor (≈ 100 mA peak, 38 kHz modulation is generated by the BK library).
• Good line-of-sight; IR learning often fails if the remote is >10 cm away or angled.
Capturing frames in OpenBK (firmware 1.18.x syntax)
startDriver IR
setPinRole 14 IRRecv # example pin numbers
setPinRole 13 IRSend
logLevel 4
set IrDbg 1 # JSON output
Console output when you press “Cool 24 °C”:
IR: {"Protocol":"LG","Bits":48,"Data":"0x8800A12405F7","RawData":[9000,4500,560,560,...],"Khz":38}
Copy this whole JSON for later replay.
Verifying / replaying
IRSend {"Protocol":"LG","Bits":48,"Data":"0x8800A12405F7"}
If the AC changes exactly as with the original remote, the capture is correct.
Building a library of frames
• Systematically capture: Power-Off, each temperature you want in COOL, DRY, FAN, etc.
• Spreadsheet recommended.
• Optional advanced path: decode the 48-bit structure
– bits 0-7 = header (0x88)
– bits 8-11 = mode
– bits 12-15 = fan speed
– bits 16-23 = temperature (temp-16 plus offset)
– bits 40-47 = checksum = sum(previous bytes) & 0xFF
If you implement this in a script you can compute any frame instead of storing hundreds of them.
Transmitting from scripts / MQTT
a) Console / HTTP
cmnd?IRSend={"Protocol":"LG","Bits":48,"Data":"0x8800A12405F7"}
b) MQTT (default OpenBK topic style)
Topic: cmnd/<devicename>/IRSend
Payload: {"Protocol":"LG","Bits":48,"Data":"0x8800A12405F7"}
Home-Assistant integration (template MQTT-Climate)
Minimal example:
mqtt:
climate:
- name: "LG Portable AC"
modes: ["off","cool","dry","fan_only"]
fan_modes: ["low","medium","high","auto"]
temperature_unit: C
min_temp: 18
max_temp: 30
command_topic: "cmnd/lg_ac/IRSend"
command_template: >
{% set m=hvac_mode | default("off") %}
{% set f=fan_mode | default("auto") %}
{% set t=temperature | int(24) %}
{% set codes = {
"off":"0x8800C00405FB",
"cool":{"low":{24:"0x8800A12405F7",25:"0x8800B12505F6"}, "auto":{24:"0x8800E12405F2"}},
"dry":"0x8800D00405FA",
"fan_only":"0x8800200405DF"
} %}
{% if m=="cool" %}
{"Protocol":"LG","Bits":48,"Data":"{{ codes.cool[f][t] }}"}
{% else %}
{"Protocol":"LG","Bits":48,"Data":"{{ codes[m] }}"}
{% endif %}
Replace the hex values with your own verified frames. Restart HA, you now get a fully integrated thermostat card.
• OpenBeken 1.18.x adds MQTT Home-Assistant auto-discovery for IR but still experimental—manual templates remain more reliable.
• The IRremoteESP8266
project keeps a continually updated LG protocol decoder; its code tables help validate your checksum calculations.
• Commercial Wi-Fi IR blasters (Tuya, Broadlink) are often switching to BK7231 chips—flashing OpenBK gives full local control without cloud dependency.
• Carrier frequency is not part of the JSON frame; IRSend
uses 38 kHz by default. If your capture shows 56 kHz (Khz":56}
) add "Khz":56
to the send command.
• Why raw is slower: The sender must reproduce every mark/space, leading to longer payloads and CPU load; protocol mode is cleaner and allows checksum auto-generation.
• Checksum example (LG 48 bit):
\[
\text{byte}5 = ( \sum{i=0}^{4} \text{byte}_i ) \& 0xFF
\]
• IR control is generally permissible for personal use; avoid redistributing proprietary code dumps without LG’s consent.
• If you expose IR control over the internet, ensure broker authentication to prevent unauthorized operation (energy misuse, equipment wear).
• Power the IR LED with a transistor + 100 Ω resistor from 5 V (VCC) if possible; BK GPIO cannot source the 100 mA peaks alone.
• Label each captured frame with date/time; some LG remotes embed a rolling counter—re-use after months may require fresh capture (rare but reported).
• During learning, cover other IR sources (TV, sunlight) to reduce spurious edges.
• Some LG portable models (e.g. LP1419) use a 56-kHz variant and 15-byte frames; the steps stay the same but the bit-mapping differs.
• Home-Assistant MQTT-Climate can only display states you publish; because the BK board is open-loop, HA will not know if someone used the physical remote unless you also pipe IRRecv
messages back into HA.
• Port the checksum calculator from IRremoteESP8266
into an OpenBK script so one MQTT message like {"mode":"cool","temp":24,"fan":"low"}
is converted locally to the correct frame.
• Investigate BK7231’s hardware PWM: native 38-kHz modulation might yield longer range than the current software driver.
• Contribute captured LG variants to the Tasmota / IRremoteESP8266 database to help other users.
LG AC remotes send long, stateful IR frames. With OpenBeken you capture those frames (IrDbg 1
), verify them via IRSend
, and publish the same JSON over MQTT from Home-Assistant. Either store every frame you need or decode the bit structure and compute frames dynamically. Once the codes are confirmed, HA scripts or a template mqtt.climate
entity give you full local, cloud-free control of the portable air conditioner.