In case anyone’s interested, I’ve started working on a component for controlling LG HVAC devices (specifically, heat pumps) on their “SmartThinQ” platform. There is no documentation yet, and it’s far from complete, but if anyone’s interested, here’s the relevant repository:
This is based on some painstaking work I did to reverse-engineer the SmartThinQ Android app to work out their API:
I’d be happy to give more details on how this project is going if anyone’s interested in helping out.
I could help out. I have the Washer and Dryer and seeing as the IFTTT integration is not working in Canada, this would be my only option for any integration.
The main thing is that I only have higher-level parameters worked out for the devices I have, which are AC units. If you’re interested, maybe you can try seeing what the API can tell you about your devices.
Concretely, try cloning the WideQ repository and running the example.py script. It should list your devices. Running python3 example.py mon <device ID>, if we’re lucky, might display the available parameters for your washer and dryer.
After quite a bit of modifying the URL and the parameters of wideq (I’m in Canada and the service I use is different) I’m able to get a listing of the WASHER and DRYER by running example.py. Running it with mon and device id though fails.
The response seems to be invalid B64:
{‘deviceId’: ‘4c722bf0-b073-11e7-a727-7c1c4e83a0e9’, ‘deviceState’: ‘E’, ‘format’: ‘B64’, ‘returnCod
e’: ‘0000’, ‘returnData’: ‘AQABAAEAAAAAAAEAAAAAqAAAAAAAAABk’, ‘stateCode’: ‘S’, ‘workId’: ‘n-6cf2464
0-bb61-4cd2-9d8b-8322d3b0ab’}
I forked your repository and added some json files I was able to get from the API. It looks promising. I’ll have to run the Washer and Dryer and get new Json files to compare.
I think we should be able to get the time remaining from the cycles through the model info.
The JSON model files can serve as a good guide. One other thing to try, if you’re interested in hacking around, would be to poke around in the JSON document that describes the device and look at the key appModuleUri. For my AC units, at least, that contains a link to a zip file containing a module for the mobile app for controlling the device. The app is a Cordova thing, so the module consists of HTML and (unobfuscated) JavaScript. The JS is not easy to read, but it can give hints about how to access the API for certain calls.
OK, so for now I’m able to poll it and get a status update. Looks like version 1 will be the status update with time remaining. I’ll need to figure out the ‘options’ (bit level? really…) and how to control the pause, power off and remote start feature later on.
I looked at the module, but this will need a more in depth analysis. That code is hard to read.
have a look at my code and let me know how I could improve it, I’m still a beginner with this stuff.
Wow; this looks cool! It looks like you’ve been able to handle a few more exceptional cases, which makes sense, and it was possible to slot in the ApplianceDevice class for this kind of device.
Maybe it would make sense for us to factor out some basic functionality for looking up configuration/setting values into a common Device base class?
A common Device would be ideal. I’ve added a smartthinq sensor as well, works for my washer and dryer.
For the components, we would need an entity_component for smarthinq, and then components for the different devices. I still need to figure out how to create components for that to happen.
For WideQ, I need to map the bits from a byte to be able to grab more info, a few fields (Options) are 1/0 mapped from bits. After that, we can refactor a Device class and then upload it to pypy I think.
Hey thanks for making this cool project. I also have the LG Smartthinq washer / dryer combo.
I am able to execute “example.py mon device-id-string”. At first I got an error code 0106 with a Korean message which read “device not connected” so I turned both washer and dryer on and re-ran example.py.
This time with a response of Polling… Polling… Polling… Then a different error message. “UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa8 in position 15: invalid start byte”
Both washer and dryer returned the same message. I can upload the error message to github if you want.
Yeah shortely after posting I tried out simlaf’s fork and got a 9003 error. It translates to “session creation failed”.
Changed simlaf’s code back to US because im not in Canada and bam it started working. It returned lots of info and a couple with error in the descriptions.
And at the end of the return on the dryer it has a traceback error “IndexError: list index out of range” Line 57 example.py. The washer did polling… polling… then listed a lot of info but then did polling… and listed the same info and went into a loop.
Good work so far guys. Any testing needed just let me know.
Dport, could you run “example.py model {device}” for both devices and provide me with the json files that get created? I could use it to refine the mapping for data.
I forgot about the country code. We should make it ask for the country.
Well too funny our model numbers are like one number off so I assumed those json files where created from my execution of example.py. However I see a wideq_state.json is this the file you were looking for? I copied only python files into a new folder and re-ran the example and those other json files were not present woops.