Skip to content

Add light switch for AC#40

Open
skinkie wants to merge 1 commit into
anszom:masterfrom
skinkie:enh_ac_light_switch
Open

Add light switch for AC#40
skinkie wants to merge 1 commit into
anszom:masterfrom
skinkie:enh_ac_light_switch

Conversation

@skinkie

@skinkie skinkie commented Apr 19, 2026

Copy link
Copy Markdown

Me: reverse engineering the protocol
Me: guessing adding the light switch
Gemini: trying to fix the code
Me: actually fixing the HomeAssistant discovery

@skinkie

skinkie commented Apr 19, 2026

Copy link
Copy Markdown
Author

Fix #38

@maciejsszmigiero

Copy link
Copy Markdown
Collaborator

What IDU model you tested this against?
Especially toggling the light ON and OFF from Home Assistant?

Quoting my PR #36:

// 0x21f - "display light" value is inverted in some devices,
// but in some devices it is not - not shown in ThinQ app either

In other words, this setting would need need at least being able to detect its "polarity".

@skinkie

skinkie commented Apr 19, 2026

Copy link
Copy Markdown
Author

What IDU model you tested this against? Especially toggling the light ON and OFF from Home Assistant?

Quoting my PR #36:

// 0x21f - "display light" value is inverted in some devices,
// but in some devices it is not - not shown in ThinQ app either

In other words, this setting would need need at least being able to detect its "polarity".

The one from #31 : AP09RK, or RAC_056905_WW by LG Firmware: 690474

@maciejsszmigiero

maciejsszmigiero commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

AP09RK

So it's a Dual Cool Deluxe with air purification device then.

Does switching the light ON and OFF from Home Assistant work?
It does not seem to do so on Standard2 or Deluxe devices, not to mention its inverted polarity on Standard2 devices.

@skinkie

skinkie commented Apr 19, 2026

Copy link
Copy Markdown
Author

Does switching the light ON and OFF from Home Assistant work?

Yes!

It does not seem to do so on Standard2 or Deluxe devices, not to mention its inverted polarity on Standard2 devices.

No experience with them, but I wonder if the function is available at all on the LG app, #41 is also not in there.

@Drafteed Drafteed left a comment

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.

Please rebase onto the master branch.

@maciejsszmigiero

Copy link
Copy Markdown
Collaborator

We still need a way to auto-detect this function presence so HA isn't filled with dead switches and sensors for each IDU.

As I wrote above a week ago, the two IDU models I have access to both have tag 0x21f, however neither one allows writing to it and they have opposite reporting polarity on top of that.

@skinkie Please post the queryCaps() result (writing tag 0x1f5 with value 1) to see if there's something there allowing identifying this display capability or at least the Dual Cool IDU type.

The recently merged TLVDevice changes should run this type of query immediately after such device connects so this query results should be visible in rethink log.

Does the proprietary ThiQ app show a display light switch for your IDU type?

@skinkie

skinkie commented Apr 26, 2026

Copy link
Copy Markdown
Author

@skinkie Please post the queryCaps() result (writing tag 0x1f5 with value 1) to see if there's something there allowing identifying this display capability or at least the Dual Cool IDU type.

Which script executes that? If I want to do it manually before running the latest merge of your work?
Could you give me a hint how to writing using packet-sender / packet-sender-device?

Does the proprietary ThiQ app show a display light switch for your IDU type?

Don't recall. And now it shows only 'disconnected'.

Solved: DNS rebind protection. My problem at this moment. I upgraded to the latest code, for this I obviously had to shutdown the program. Airco does not reconnect to it, even after complete power off. I'll try to hookup the external DNS server tomorrow to see what it queries.

@skinkie

skinkie commented Apr 27, 2026

Copy link
Copy Markdown
Author

@maciejsszmigiero can you comment on this one too? How do I send the command?

@maciejsszmigiero

maciejsszmigiero commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Try something like npx tsx packet-sender.ts (MQTT server name and port) (device UUID) 01 01 02 02 01 0x1f5 1

Edit: To be clear, the MQTT server name is of the rethink built-in server, rather than the external HA one.

@skinkie

skinkie commented Apr 27, 2026

Copy link
Copy Markdown
Author

@maciejsszmigiero

{"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","mid":1777328040947,"cmd":"packet","type":1,"data":"01010400000065020201027d416a0d"}

Would love to understand the meaning of the 01 01 02 02 01.

@maciejsszmigiero

Copy link
Copy Markdown
Collaborator

That's the outgoing query packet to the device.

We are interested in the incoming response to that packet from the device - it will have "cmd":"device_packet" in it.

Would love to understand the meaning of the 01 01 02 02 01.

Me too :)

These numbers come from what the official cloud sends, there are some ideas what these could mean in the "TLVProtocol" page in Wiki.

@skinkie

skinkie commented Apr 27, 2026

Copy link
Copy Markdown
Author

@maciejsszmigiero Something like this?

2026-04-27T22:33:01.857Z incoming lime/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","mid":1777329181818,"cmd":"packet","type":1,"data":"01010400000065020201027d416a0d"}  retain: false
2026-04-27T22:33:02.174Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13505452,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702016875B001E180B05077B0A0017CD401B85024B8903CB8D020B9103CBAD024BB103CB0C1B103B307B280B2C0B34FB49020B4E01011B582B541B543D3C0B6A0551DB6F0690474B701B7501EBC40BD00BD4FB5C0B61024B642B5C1B600B642B5C2B600B642B5C4B61029B642B5C5B600B642B5C6B6102CB642A175","type":1} retain: false
2026-04-27T22:33:02.175Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:02.539Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13505817,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702016975B001E180B05077B0A0017CD401B85024B8903CB8D020B9103CBAD024BB103CB0C1B103B307B280B2C0B34FB49020B4E01011B582B541B543D3C0B6A0551DB6F0690474B701B7501EBC40BD00BD4FB5C0B61024B642B5C1B600B642B5C2B600B642B5C4B61029B642B5C5B600B642B5C6B6102CB6427339","type":1} retain: false
2026-04-27T22:33:02.540Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:02.729Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13506012,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0301040000008701100000EC3C","type":1} retain: false
2026-04-27T22:33:02.912Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13506190,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702016A75B001E180B05077B0A0017CD401B85024B8903CB8D020B9103CBAD024BB103CB0C1B103B307B280B2C0B34FB49020B4E01011B582B541B543D3C0B6A0551DB6F0690474B701B7501EBC40BD00BD4FB5C0B61024B642B5C1B600B642B5C2B600B642B5C4B61029B642B5C5B600B642B5C6B6102CB64215CC","type":1} retain: false
2026-04-27T22:33:02.913Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:03.738Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13507020,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702046B0A8CA004418CCBACE002FF3498","type":1} retain: false
2026-04-27T22:33:03.738Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:04.375Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13507658,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702046D02CD48464C","type":1} retain: false
2026-04-27T22:33:04.375Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:05.287Z incoming clip/message/devices/4c48c617-7eb1-1fc9-a24a-64cbe91237a8 {"mid":87962014,"did":"4c48c617-7eb1-1fc9-a24a-64cbe91237a8","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-62,"fs":"idle","br":9600,"data":"000004000000870204E402CD486803","type":1} retain: false
2026-04-27T22:33:05.287Z status 4c48c617-7eb1-1fc9-a24a-64cbe91237a8 received TLV packet
2026-04-27T22:33:09.904Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13513188,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"00000400000087020471038A1021B6AF","type":1} retain: false
2026-04-27T22:33:09.904Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:10.321Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13513605,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702047202CD499924","type":1} retain: false
2026-04-27T22:33:10.321Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:11.369Z incoming clip/message/devices/4c48c617-7eb1-1fc9-a24a-64cbe91237a8 {"mid":87968096,"did":"4c48c617-7eb1-1fc9-a24a-64cbe91237a8","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-62,"fs":"idle","br":9600,"data":"000004000000870204E502CD490E96","type":1} retain: false
2026-04-27T22:33:11.370Z status 4c48c617-7eb1-1fc9-a24a-64cbe91237a8 received TLV packet
2026-04-27T22:33:16.636Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13519919,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702047402CD4A8EDE","type":1} retain: false
2026-04-27T22:33:16.636Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:22.537Z incoming clip/message/devices/4b1a5154-ae3c-1df5-8c7c-64cbe91238bd {"mid":13525821,"did":"4b1a5154-ae3c-1df5-8c7c-64cbe91238bd","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-55,"fs":"idle","br":9600,"data":"0000040000008702047602CD4953D5","type":1} retain: false
2026-04-27T22:33:22.537Z status 4b1a5154-ae3c-1df5-8c7c-64cbe91238bd received TLV packet
2026-04-27T22:33:23.176Z incoming clip/message/devices/4c48c617-7eb1-1fc9-a24a-64cbe91237a8 {"mid":87979889,"did":"4c48c617-7eb1-1fc9-a24a-64cbe91237a8","kind":"RAC_056905_WW","cmd":"device_packet","rssi":-62,"fs":"idle","br":9600,"data":"000004000000870204E902CD4A71C7","type":1} retain: false

@maciejsszmigiero

Copy link
Copy Markdown
Collaborator

Yes, 0000040000008702016875B001E180B05077B0A0017CD401B85024B8903CB8D020B9103CBAD024BB103CB0C1B103B307B280B2C0B34FB49020B4E01011B582B541B543D3C0B6A0551DB6F0690474B701B7501EBC40BD00BD4FB5C0B61024B642B5C1B600B642B5C2B600B642B5C4B61029B642B5C5B600B642B5C6B6102CB642A175 decodes to:

t=0x2c0 l=0 v=0x1 (1)
t=0x386 l=0 v=0x0 (0)
t=0x2c1 l=1 v=0x77 (119)
t=0x2c2 l=2 v=0x17c (380)
t=0x350 l=0 v=0x1 (1)
t=0x2e1 l=1 v=0x24 (36)
t=0x2e2 l=1 v=0x3c (60)
t=0x2e3 l=1 v=0x20 (32)
t=0x2e4 l=1 v=0x3c (60)
t=0x2eb l=1 v=0x24 (36)
t=0x2ec l=1 v=0x3c (60)
t=0x2c3 l=0 v=0x1 (1)
t=0x2c4 l=0 v=0x3 (3)
t=0x2cc l=0 v=0x7 (7)
t=0x2ca l=0 v=0x0 (0)
t=0x2cb l=0 v=0x0 (0)
t=0x2cd l=0 v=0xf (15)
t=0x2d2 l=1 v=0x20 (32)
t=0x2d3 l=2 v=0x1011 (4113)
t=0x2d6 l=0 v=0x2 (2)
t=0x2d5 l=0 v=0x1 (1)
t=0x2d5 l=0 v=0x3 (3)
t=0x34f l=0 v=0x0 (0)
t=0x2da l=2 v=0x551d (21789)
t=0x2db l=3 v=0x690474 (6882420)
t=0x2dc l=0 v=0x1 (1)
t=0x2dd l=1 v=0x1e (30)
t=0x2f1 l=0 v=0x0 (0)
t=0x2f4 l=0 v=0x0 (0)
t=0x2f5 l=0 v=0xf (15)
t=0x2d7 l=0 v=0x0 (0)
t=0x2d8 l=1 v=0x24 (36)
t=0x2d9 l=0 v=0x2 (2)
t=0x2d7 l=0 v=0x1 (1)
t=0x2d8 l=0 v=0x0 (0)
t=0x2d9 l=0 v=0x2 (2)
t=0x2d7 l=0 v=0x2 (2)
t=0x2d8 l=0 v=0x0 (0)
t=0x2d9 l=0 v=0x2 (2)
t=0x2d7 l=0 v=0x4 (4)
t=0x2d8 l=1 v=0x29 (41)
t=0x2d9 l=0 v=0x2 (2)
t=0x2d7 l=0 v=0x5 (5)
t=0x2d8 l=0 v=0x0 (0)
t=0x2d9 l=0 v=0x2 (2)
t=0x2d7 l=0 v=0x6 (6)
t=0x2d8 l=1 v=0x2c (44)
t=0x2d9 l=0 v=0x2 (2)

Let me figure out what can be done here when I have a spare moment...

@maciejsszmigiero

Copy link
Copy Markdown
Collaborator

The BRIGHTNESS_CONTROL capability bit should be bit 1 (mask value of 2) of tag 0x2d6.

Since this bit is apparently also set on devices with broken/reverse polarity light switch at tag 0x21f we also have to use the "eeprom checksum" field value (at tag 0x2da) as selector of known-working devices for now - currently only your Dual Cool model value of 0x551d will be allow-listed for this light switch capability.

In the future it might be possible to use the firmware version tag 0x2db instead, however we currently don't have enough samples to figure out whether the fact that the light switch is working properly is indeed firmware version dependent and not hardware model dependent.

@skinkie

skinkie commented May 5, 2026

Copy link
Copy Markdown
Author

@maciejsszmigiero how did you found out?

@maciejsszmigiero

Copy link
Copy Markdown
Collaborator

These capability bits are described in a model JSON file that ThinQ API returns in the device list.

Then capability tag to capability bits can be inferred by comparing which tags have the same bits set as bits in the model JSON file.

@skinkie

skinkie commented May 5, 2026

Copy link
Copy Markdown
Author

These capability bits are described in a model JSON file that ThinQ API returns in the device list.

Then capability tag to capability bits can be inferred by comparing which tags have the same bits set as bits in the model JSON file.

Can we make this output documentation somewhere on the wiki?

@anszom

anszom commented May 7, 2026

Copy link
Copy Markdown
Owner

Can we make this output documentation somewhere on the wiki?

I second that :)

@maciejsszmigiero I've sent you a collaborator invitation in case you'd like to update the wiki.

@maciejsszmigiero

Copy link
Copy Markdown
Collaborator

Thanks @anszom - it's nice to be able to improve knowledge in the Wiki from time to time.

Can we make this output documentation somewhere on the wiki?

We'll see what could be done there in the longer term, however there's still a lot of manual guesswork required.

@anszom

anszom commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Just checked my unit, and it reports the light state with inverted polarity. Writing the value makes the AC beep, but doesn't affect the light.

0x2da=0x4d81
0x2db=0x690409

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.

4 participants