MY GOD - Anyone attempted an LG ThinQ integration?

Has anyone attempted an LG ThinQ integration? I have never seen something this over engineered in my life! I'm making headway, but just curious if anyone else has any experience?

1 Like

After much cursing, yelling, and a little drinking, I finally succeeded in getting HE to connect to their MQTTS server. Three different apis, 5 servers, 3 different protocols... what a mess. Now I just need my ThinQ appliances to arrive so I can finish it up!

Just yesterday I was thinking about this looking at going the node-red route.

Curious, what devices do you have? I plan to add support for the dishwasher, fridge, and stove at least since that’s what I have coming.

I don’t have any yet but planning on buying a clothes washer and dryer.

If I get things working for the devices I have I’ll take a look at washer and dryer support. No promises though, really hard to build when I don’t have the devices to test with.

Nice, I was also trying to find information to integrate my washer but also found that is was going to be messy / rabbit hole.

So you guys have any raw code? We could also team up and work on this together.

I have an LG smart DW and dual fuel range.

I don't code, but can help test.

P.S. Hope you have better luck keeping yours running than I. But that's off topic.

Could you please share any details about your findings?

I've not looked at this in detail, but did have a look some time ago and found this:

Do you have to integrate with ThinQ specifically, or are you just trying to control your LG TV running WebOS? If the latter, check out this thread.

I'll post some code and notes later this evening. Definitely happy to have help. Note code is VERY ugly right now because it's more me playing around and trying to figure out the data.

I saw that. Wideq seems to use their v1 api, not their v2. I found two libraries that have helped investigate. One is a wideq port, GitHub - tinkerborg/wideq at api2 and the other a python lib GitHub - tinkerborg/thinq2-python: Reverse-engineered client for LG ThinQ v2 IoT devices

Thanks, but no this isn't related to the TV. I am trying to integrate with LG appliances (stove, fridge, dishwasher, etc.). That integration, unfortunately, doesn't apply as the TV uses a very different process.

1 Like

Rough, ugly, dirty, bad code is available at GitHub - dcmeglio/hubitat-thinq

Info:

  • Right now I just have an app, install it. When you run it, click the href and it will load the LG login. After you click Sign In you'll get redirected to a page (your browser might htink it's Korean). Copy the URL you're redirected to. Close the popup, wait for the HE App to reload and paste that URL into the URL textbox in the app. Click Next. At this point it will create a log message of the detected devices.

My next steps:

  • Get the device types for the appliances we care about (the app supports many more than actually can be integrated)
  • Create child devices for each selected appliance
  • Declare one appliance to be the main one that will have the MQTT connection - only 1 user can connect to the MQTT so we need one to act as a gateway for all the other appliances since we can't do MQTT in an app.

Note, right now it will only work in the US because we need to figure out the country codes.

Here is some of my research so far:

1.) Retrieve API endpoints from main URL

  • Q: What are the valid country and language codes? US and en-US work, I read online Poland is PL and en-EN? Others?
  • This gives us the OAuth URL (empUri) and API URL (thinqUri)

2.) Initiate OAuth using empUri and various params

  • Q: Anyway to get the redirect_uri to change to use regular HE OAuth? Thinking no since we can't get a partner account to set our own uri
  • User pastes resulting URL into HE app and we parse to get user_number, code, and URL to request OAuth token
  • Call OAuth token URL with code to get token and refresh token
  • TODO: Figure out error codes so we know when to refresh

3.) Register (login?) with API

4.) Retrieve MQTT server address from route URL

  • Q: What's this apiURL?

5.) Request device list from API

6.) Generate private RSA key and CSR -- this has to be done outside of HE

7.) Submit CSR to cert endpoint and get back cert + MQTT topic

8.) Connect to MQTT

Q: How do we send commands?
Q: What does the data we get back from MQTT look like?

Notes:
Lots of custom HTTP headers and magic numbers, some needed some not
Some endpoints respond with invalid HTTP replies, especially for errors, and HE doesn't like this

3 Likes

Updates (9/30):

  • Found a way to get country/lang codes.
  • Got device list and created children
    Updates (10/1):
  • Added a setting so you can now choose your country/language. Their list is stupid. Why is United Arab Emirates the first in the list??? Why say United Arab Emirates and not UAE, but display USA instead of United States??? Who knows, this is what LG provides!
  • Added some really basic help text for how to do the OAuth and certs
  • Added code to submit the CSR to LG to get a cert back

I'm curious if anyone out there who actually owns ThinQ appliances can figure this out far enough to see if it detects your appliances? My fridge won't be here till 10/10 and my oven and dishwasher won't be here till 11/14 so it makes testing difficult :slight_smile:

Happy for any help others can provide!

3 Likes

No time tonight, but maybe tomorrow or this weekend I can give it a try with our washer/dryer set (WM3900HWA & DLGX3901W). It would be pretty cool if I could have Alexa announce when a load has finished...

2 Likes

Long rough week, but I'll try to look at this over the weekend.

I don't have a smart fridge, but have the range and DW.

1 Like

Nice stuff I'll give this one a try and help code whats needed.
Thanks for the initial ground work!

1 Like

@darren3220

6.) Generate private RSA key and CSR -- this has to be done outside of HE

Could you please add a bit more details on what attributes the certs must have, must the dns match something?

I literally left everything blank on that cert website. I don’t think there are any specifics needed other than 2048 bit

I have a really rough code sample to do the mqtt connection but I’m not home right now so I can’t post it.