sampsyo / wideq

reverse-engineered client for the LG SmartThinQ API
https://pypi.org/project/wideq/
MIT License
326 stars 160 forks source link

Controlling APIv2 devices #108

Open ljtilley opened 4 years ago

ljtilley commented 4 years ago

I did some poking around on how to control devices that are using APIv2 and found that you use the following endpoint to send commands:

POST https://aic-service.lgthinq.com:46030/v1/service/devices/{device-id}/control-sync Request Body: { "command": "Operation", "ctrlKey": "basicCtrl", "dataKey": "airState.operation", "dataValue": "0" }

The request body basically matched the json model info that you can dump using the existing code. I tried directly copying this by re-implementing the post function in the code, but it was returning a '9999' error.

Then I did some research and found another library called thinq2-python that seems to have made a bunch more headway in reverse engineering the new API.

I think the key is registering the client id after you get your oauth token but before you try to issue commands. you register a client by doing a POST request to https://aic-service.lgthinq.com:46030/v1/service/users/client and you can check if a client is already registered by doing a GET at the same address.

The thinq2-python library generates the client id as a 32 byte random hex value (secrets.token_hex(32)) but when I dissassembled the LG Thinq apk it looks like they generate it as a base64 encoded uuid, but the end result works either way.

sampsyo commented 4 years ago

Indeed! We are actually in the process of trying to merge in APIv2 support from ollo69's fork in https://github.com/sampsyo/wideq/pull/100. There is a lot of work to do still, but the basics are there—including, I think, the client ID registration stuff. We could use all the help we can get, if you're interested. :smiley:

digginsa commented 4 years ago

Indeed! We are actually in the process of trying to merge in APIv2 support from ollo69's fork in #100. There is a lot of work to do still, but the basics are there—including, I think, the client ID registration stuff. We could use all the help we can get, if you're interested. 😃

I dont have any programming experience, but have two AC units (on APIv2 in the UK )and 24 years IT experience so happy to test anything if needed.

pifou25 commented 4 years ago

How can we check if any device should use Wideq APIv1 or the LG APIv2 protocol ?

codeplexnl commented 4 years ago

Indeed! We are actually in the process of trying to merge in APIv2 support from ollo69's fork in #100. There is a lot of work to do still, but the basics are there—including, I think, the client ID registration stuff. We could use all the help we can get, if you're interested. 😃

I have a multi-split airco system that uses v2 and would like to have it integrated :D Is there something i can do to help integrate V2?

netdiag commented 4 years ago

Hi I've got a Therma-V Low Temp Split (HU091-U43) unit installed and am just looking at installing the WiFi Modem in order to gain remote access etc. More than happy to help with this work If I can.

TheGabeMan commented 3 years ago

Owner of 1x PC09SQ and 2x PC18SQ LG Airco's. I'd be happy to help with debugging.

jacekpaszkowski commented 3 years ago

Hello, i also can help with debugging. I have 1 x DC12RQ and 2 x DC09RQ :)

Looking forward for v2 support :)

majki09 commented 3 years ago

Thank you @sampsyo and @no2chem for your work and making people happier! For long time I was searching, trying and disassembling the mobile app and finally I've found your repo.

I've made a domoticz plugin which uses v2 API. Even if domoticz is not you friend, you can step in to my repo to propose a change, submit the issue ticket or just review the code.

v2 API domoticz plugin here: domoticz_lg_thinq_plugin