Skip to content

Expand LG RAC support (deviceType 401, modern caps & 0xA7 TLV) - #143

Open
Nacorsito wants to merge 7 commits into
anszom:masterfrom
Nacorsito:feature/lg-modern-ac-support
Open

Expand LG RAC support (deviceType 401, modern caps & 0xA7 TLV)#143
Nacorsito wants to merge 7 commits into
anszom:masterfrom
Nacorsito:feature/lg-modern-ac-support

Conversation

@Nacorsito

@Nacorsito Nacorsito commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Adds support for modern LG DualCool Room Air Conditioners (RAC) running newer firmware (917be and European/Global WZ/S3NW inverter series), improves provisioning reliability with custom CA certs, and formats the supported appliances list in README.md into a structured table with contributor attribution.

Key Changes

  1. Capabilities Tag Detection (cloud/devices/RAC_056905_WW.ts):

    • Newer RAC firmware omits the legacy 0x2da EEPROM tag, sending 0x2db or 0x2c1 instead.
    • Expanded isCapsResponse() to accept 0x2db and 0x2c1 to prevent devices from getting stuck in a capabilities query retry loop.
  2. TLV Private Data Command Byte (cloud/devices/tlv_device.ts):

    • Allow 0xA7 command bytes alongside 0x87 in processPrivData and processPrivDataCmdResp frames.
  3. HA Bridge Model Aliases & Fallbacks (cloud/ha_bridge.ts):

    • Added explicit mappings for WZ12AWN, WZ18AWN, and S3NW series.
    • Added fallback logic: when meta.modelId is not found, fallback to meta.modelName or map appliances reporting deviceType === 401 / RAC_ to RAC_056905_WW.
  4. Dynamic RSA Key in Provisioning Tool (rethink-setup.ts):

    • Extracts the public key dynamically from ./data/ca.cert using Node crypto (falling back to bundled key), fixing encryptRes:ffff errors when custom CA certificates are generated.
    • Added connection (4s) and read (3s) socket timeouts so thinq1Setup gracefully falls through to thinq2Setup without hanging.
  5. Unit Tests & Documentation:

    • Added tests/cloud/ha_bridge.test.ts for model matching & fallbacks.
    • Added 0xA7 modern caps test in tests/cloud/devices/RAC_056905_WW.test.ts.
    • Converted README.md supported appliances list into a clean, categorized table with contributor credits.

Testing

  • Tested on physical LG DualCool units (WZ12AWN SNU3 / S3NW12TZXBB and WZ18AWN SNU1 / S3NW18TZXBA) with full bidirectional Home Assistant climate control and live telemetry.
  • All test suites passing (npm test).
  • TypeScript build succeeds cleanly (npm run build).

Modern LG Room Air Conditioners running newer firmware variants (e.g. 917be)
omit the legacy EEPROM checksum tag (0x2da) in their capabilities payload,
reporting tags 0x2db or 0x2c1 instead. Without recognizing these tags,
isCapsResponse fails and the device loops in capabilities query timeout.

Expand isCapsResponse to accept 0x2db and 0x2c1 alongside 0x2da.
Follow-up to 931a3d8: allow 0xA7 in addition to 0x87 for processPrivData
and processPrivDataCmdResp frames sent by newer appliances.
Many LG Room Air Conditioners present model names (e.g. WZ12AWN, WZ18AWN,
S3NW12TZXBB, S3NW18TZXBA) or identify generically as deviceType 401
during ThinQ v2 registration without an exact match for meta.modelId.

This patch:
- Adds explicit model aliases for common WZ and S3NW RAC model series.
- Adds fallback matching by meta.modelName when meta.modelId is missing.
- Adds fallback resolution to RAC_056905_WW when deviceType is 401 or
  the model starts with RAC_/WZ/S3NW.
- Extract the RSA public key dynamically from ca.cert (with fallback to
  bundled key) so appliances encrypt provisioning credentials using the
  active local CA certificate instead of failing with encryptRes:ffff.
- Dynamically resolve hostname, https_port, and mqtts_port from config.json.
- Add connection (4s) and data (3s) timeouts to request() so thinq1Setup
  cleanly falls through to thinq2Setup without hanging indefinitely on
  ThinQ2 appliances.
- Add timeout guard to thinq2Setup socket connection.
Add comprehensive unit tests verifying that WZ, S3NW, RAC_ prefix,
and deviceType 401 models are correctly mapped to RAC_056905_WW.
isCapsResponse(tlvArray: TLV.TLV[]) {
/* eeprom checksum */
return tlvArray.some(({ t, v }) => t === 0x2da)
/* eeprom checksum (0x2da on older firmware, 0x2db or 0x2c1 on modern firmware) */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's obviously wrong since 0x2db is probably a FW version while 0x2c1 is support.airState.opMode.
And they are present on older FW versions too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the quick response. I don't know much about this protocol, i tried to follow the guide for adding support for new devices with some LLM help and after whole days it finally found a solution that worked for both my devices (WZ12AWN + WZ18AWN) and if im not wrong with some others that use the same internals. I debated about opening the PR because I couldn't 100% vouch for the code but i decided sharing the solution so someone with more knowledge can make use of it and save some time when adding support for those devices.

TLDR: I dont know much about the protocol, LLM produced some hallucinations but underlying fix works and is fully tested by hand on real hardware so i'd rather share it than leave it hidden in a drawer.

@Nacorsito Nacorsito changed the title Feature/lg_modern_AC_support Expand LG RAC support (deviceType 401, modern caps & 0xA7 TLV) Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants