Open alexanv1 opened 5 years ago
I've got a similar issue, it will poll the Refrigerator, Dishwasher, and Stove but not the new Washer and Dryer.
same here :) no errors and just no washer reporting
I've been trying to put some effort behind this when I can. It looks like my smart thinQ app calls up aic.lgthinq.com and not kic.kgthinq.com. I also hit both the us.lgeapi.com and kr.lgeapi.com. I haven't got very far outside trying to work backwards how all of the various forked components work since It seems everyone forked and made it work for their various setups. So far I put a lot of time into doing some research.
Question for those that don't get the washer or dryer to show, when did you add it to smart thinQ? Curious if there is a correlation between a new set of servers and APIs for newly added components.
@geekofweek I also do not see my washer (it is the only LG device I have so I'm not sure about the other devices). I added it on 10/12/19 through the Android SmartThinQ app.
I cannot see either my washer or dryer. No errors, just blank. First registered on the 16th of October.
Same here, just blank no errors first registered last week 10/27/19. Only an LG washer on my account
It seems all newly registered devices are using a new private API to communicate with LG. I've been trying to get my new heat pumps hooked up, none of them are listed by this library. I've been using charles proxy to examine the API requests that are happening in the mobile app. From initial testing, the calls are fairly complex and require alot of header values for the server to accept them. I wish LG would provide a public API, or at the very least allow scheduled temperature changes in their own app. The new hosts I'm seeing are aic-service.lgthinq.com
and aic.lgthinq.com
.
That's too bad! Indeed, we can all lament the lack of a public API. I spent a ridiculously large amount of time with mitmproxy, disassemblers, and staring at obfuscated JavaScript source to figure out the old API. Seems like the same process might be necessary again for the new API.
Man this really is unfortunate, I was looking forward to tying this into HASS and getting some feedback on Alexa when the washer finishes. Wanted to help out with this effort but I'm not sure if I would be able to assist with any disassembly.
I've got a good chunk of the new API figured out. The holiday here in the US will interrupt progress, but I'll try to get this finished this weekend and get a PR in.
I haven't forgotten about this, but I probably got a bit overconfident after my initial progress, and it's taking a bit longer than I figured. 😁 While the old oauth tokens work, there is now a x-user-no
header required. This user number is included in the redirect URL for the new oauth flow, which I've now got implemented. As an upshot, this also makes third-party logins work fine, though I only tested with Google.
I've also got the client.devices
functionality working, so the ls
in example.py
is working with the new API:
$ python3 example.py ls
Session expired.
a8349720-7080-11d3-92d4-XXXXXXXXXXXX: Washer (WASHER F3L2CYU__)
407b7e7d-2c14-169a-bb64-XXXXXXXXXXXX: Dryer (DRYER RV13B6BSD_D_US_WIFI)
Currently working on getting the monitor functionality working. If anyone would like to help this effort, especially if you have a mix of devices using the old and new API, let me know and I can push my fork and make you a collaborator.
hey @tinkerborg I'm not sure how much time I might have. But I currently have an LG email only login (no third party flow) with only the US based Washer (on the new API change). I would definitely give it a look through, but not sure how much debugging I can do at the current moment.
Let me know how I can contribute or test anything
I seem to be in the same boat with the new API. Account was created this week with a washer and dryer added to the account. Looking forward to trying your latest updates.
Hey @tinkerborg I’d like to take a look at your fork. May be able to help with the effort. Only have new devices.
+1
I just tried to get a capture of the network traffic of the latest Android Thinq app, but actually failed with mitm :( It seems like LG started to use certificate pinning.
I did get a capture w/ a mitm proxy and was able to get the auth flow working, and a device list. Where I left off was working on monitor functionality. Sorry I've been unresponsive, things have been a bit hectic with work. I'll pick this back up tonight and get my fork up so folks can help get the rest working.
FWIW, when I did the original reverse engineering, I had to disable certificate pinning. This, unfortunately, required disabling two integrity checks that the app did to try to prevent tampering (one implemented in Java, which was easy, and another implemented in C/native code, which required manually editing instructions).
OK, finally got my code pushed. Note it's very rough, I was in the middle of trying to get both API versions to coexist when I last worked on this. You should be able to go through the whole auth flow against the new API endpoints, and facebook,google and amazon auth should work fine now too.
Once authenticated you should be able to pull a device list but monitor functionality is not working yet.
@martinc and @gladhorn I added you as collaborators, if anyone else wants access let me know. api2
branch on my fork here: https://github.com/tinkerborg/wideq/tree/api2
Fantastic, I'll try to give this ago today or tomorrow and pull down your fork in my setup. Will get back to you here if I'm seeing my Washer.
Thank you for your efforts thus far @tinkerborg
Fantastic, I'll try to give this ago today or tomorrow and pull down your fork in my setup. Will get back to you here if I'm seeing my Washer.
Cool, I added you as a collaborator on my fork too. In theory it should see your washer, it sees my W/D w/ the new API.
im test example.py -c RU -l ru-RU at russian. Logging at site, copy url back and Have a error AttributeError: module 'wideq' has no attribute 'NotLoggedInError'
im test example.py -c RU -l ru-RU at russian. Logging at site, copy url back and Have a error AttributeError: module 'wideq' has no attribute 'NotLoggedInError'
Should be fixed.
im test example.py -c RU -l ru-RU at russian. Logging at site, copy url back and Have a error AttributeError: module 'wideq' has no attribute 'NotLoggedInError'
Should be fixed.
Hi. Now i see cyrcle message. Session expired. Session expired. Session expired.
And no show device. But to account attach refrige and washer. (use mail pass account)
@tayanov https://github.com/tinkerborg/wideq/pull/1 should fix your issue. After that I still cannot see any devices, but at least the authentication works for me.
@tayanov tinkerborg#1 should fix your issue. After that I still cannot see any devices, but at least the authentication works for me.
Latest commit should fix that, I think. Forgot to have it use the API URL returned by the gateway.
Ok so I was able to sit down and try this new fork out. I switched over to the api2 branch and get the following error.
Traceback (most recent call last):
File "example.py", line 225, in <module>
main()
File "example.py", line 221, in main
example(args.country, args.language, args.cmd, args.args)
File "example.py", line 168, in example
client = wideq.Client.load(state)
File "/home/homeassistant/.homeassistant/custom_components/smartthinq/wideq-modified/wideq/client.py", line 157, in load
client._auth = core.Auth.load(client._gateway, data)
File "/home/homeassistant/.homeassistant/custom_components/smartthinq/wideq-modified/wideq/core_v2.py", line 262, in load
return cls(gateway, data['oauth_url'], data['access_token'], data['refresh_token'], data['user_number'])
KeyError: 'oauth_url'
Deleted my .json file, tried to re-auth again on the api2 branch. I use the new URL but then it leads me to a page not found LG account site.
I noticed in my new URL that the language is just "s"
https://us.m.lgaccount.com/spx/login/signIn?country=US&language=s
I changed the language to "en-us", shows me a proper login web page. When I go to login and use the new URL I get the following error:
https://kr.m.lgaccount.com/login/iabClose?state=<STATE>&code=<CODE>&user_number=<USER_NUMBER>&oauth2_backend_url=https%3A%2F%2Fus.lgeapi.com%2F
Traceback (most recent call last):
File "example.py", line 225, in <module>
main()
File "example.py", line 221, in main
example(args.country, args.language, args.cmd, args.args)
File "example.py", line 181, in example
example_command(client, cmd, args)
File "example.py", line 157, in example_command
func(client, *args)
File "example.py", line 26, in ls
for device in client.devices:
File "/home/homeassistant/.homeassistant/custom_components/smartthinq/wideq-modified/wideq/client.py", line 126, in devices
self._devices = self.session.get_devices()
File "/home/homeassistant/.homeassistant/custom_components/smartthinq/wideq-modified/wideq/core_v2.py", line 292, in get_devices
return get_list(self.get2('service/application/dashboard'), 'item')
File "/home/homeassistant/.homeassistant/custom_components/smartthinq/wideq-modified/wideq/core_v2.py", line 285, in get2
return thinq2_get(url, self.auth.access_token, self.auth.user_number, country=self.auth.gateway.country, language=self.auth.gateway.language)
File "/home/homeassistant/.homeassistant/custom_components/smartthinq/wideq-modified/wideq/core_v2.py", line 115, in thinq2_get
raise APIError(code, "error")
wideq.core_exceptions.APIError: ('9999', 'error')```
Nevermind! I got it working. First time I ran it with the following:
python3 example.py -c US -l en-US -ls
Which looked like it caused some problems in the URL paths. Ran it again with the standard:
python3 example.py -c US -l en-US
Now I get the Washer!
<Device ID>: Washer (WASHER <model>_US_WIFI)
Now iam too see Washer. Whats component to use with home assistant?
@rwarner The command is "ls", not "-ls" (drop the minus). @tayanov currently it's not there yet, it can only list devices with the new API, but nothing more. That's not useful in home assistant.
I also see my washer and dryer now finally \o/ progress.
@rwarner Команда "ls", а не "-ls" (минус). @tayanov в данный момент его еще нет, он может перечислять только устройства с новым API, но не более того. Это не полезно в домашнем помощнике.
Я также вижу мою стиральную машину и сушилку теперь наконец \ O / прогресс.
may be @sampsyo can add this apiv2 to self repo?
@gladhorn good point. Just so used to ls -la
... for example.
I tried to run monitor and get things working but wasn't successful last night. Wasn't able to get an appropriate response after trying to implement the lgedm_post()
method. Was erroring out. I assume like tinkerborg said earlier the monitor has to be finished, but didn't know where to start besides post and bringing in the right headers. I might not have enough information myself from sniffing the traffic / apis like you guys might have.
@tayanov Yes, the goal is a pull request but it's premature for that right now.
@rwarner It uses a totally different endpoint and header format, so the old lgedm_post()
won't be useful for the new API. I'll try to pick this up again tonight/this weekend and see if I can get monitor working.
@tinkerborg yeah I had a feeling that was probably the case. Thanks for verifying, glad I just went to bed.
Do you mind if I ask how I might go about reproducing the methods you're using for figuring out the endpoints / headers? Or is that better off letting you wrap it up if you have it all on your end.
I'll prepare some merge requests to slowly add the new API in parallel with the existing code. Note that this is not production ready, there is no way to use it in home assistant yet.
@tinkerborg in case you continue working on this, I took your code and merged it into the original code (I gave up trying to maintain both in parallel). Feel free to continue on top of https://github.com/gladhorn/wideq/tree/api2_merged
@tinkerborg in case you continue working on this, I took your code and merged it into the original code (I gave up trying to maintain both in parallel). Feel free to continue on top of https://github.com/gladhorn/wideq/tree/api2_merged
I had kept them separate intentionally, with the goal of supporting both APIs. The idea was to ultimately move any common logic into a base class from which both cores inherit, and submit a PR back to the original repo.
@tinkerborg in case you continue working on this, I took your code and merged it into the original code (I gave up trying to maintain both in parallel). Feel free to continue on top of https://github.com/gladhorn/wideq/tree/api2_merged
I had kept them separate intentionally, with the goal of supporting both APIs. The idea was to ultimately move any common logic into a base class from which both cores inherit, and submit a PR back to the original repo.
Sure, I just wonder, if there's any point in keeping both APIs working - I think LG has moved on, so we should rather focus on getting one of the APIs working sensibly. The new API should work for all devices as far as I can tell, so I'd just go for that. Anyway, we'll have to get it to work first, then it can always be refactored to either support both or just one. Thanks for your work! Feel free to just continue with your branch :) I just had to play with it, since I usually understand code a lot better by somehow changing it, so it's generally a good learning experience to try moving stuff around.
This one finally worked for me :+1: https://github.com/gladhorn/wideq/tree/api2_merged
Этот наконец-то сработал для меня https://github.com/gladhorn/wideq/tree/api2_merged
with ha?
Этот наконец-то сработал для меня https://github.com/gladhorn/wideq/tree/api2_merged
with ha?
i'm running Hassio and I'm currently trying to implement it in, so can't confirm just yet.
None of the current code with APIv2 supports monitoring so it wouldn't be able to be "implemented into HA" until the code supports such a thing. AFAIK
Unless "api2_merged" branch has resolved this. My understanding was that the "api2_merged" was just squashed ontop of the original codebase but wouldn't support monitoring
Ok I finally got a chance to work on it today. I was able to get POST working, and have tested monitoring and commanding my heat pumps, and it's working!
@tinkerborg here's my PR: https://github.com/tinkerborg/wideq/pull/4/files
Ok I finally got a chance to work on it today. I was able to get POST working, and have tested monitoring and commanding my heat pumps, and it's working!
@tinkerborg here's my PR: https://github.com/tinkerborg/wideq/pull/4/files
hey thanks for your hard work. I'm a total noob and have been trying to use the home bridge version of this but it seems to have stopped working. Any chance you can help me fix this one?
FYI, @jmh600cbr, the bottom line is that I don't think the work is ready yet for you to use. People are still working on making it work in Python. The Homebridge plugin relies on a JavaScript port, so that will likely take longer.
FYI, @jmh600cbr, the bottom line is that I don't think the work is ready yet for you to use. People are still working on making it work in Python. The Homebridge plugin relies on a JavaScript port, so that will likely take longer.
Thanks! Hoping for results soon! Wish I knew how to help.
@jmh600cbr Thanks for the effort, but that is still hitting the old device URL, so it won't work with devices like my washer/dryer.
That said, I've made a big breakthrough tonight and have the pieces needed to implement monitor functionality. I need to call it a night for now, and I have a lot of cleanup to do before sharing, but stay tuned...
May not get to work on it again until the weekend due to work, but I expect to have this working then.
- {"data":{"state":{"reported":{"meta":{"allDeviceInfoUpdate":false,"messageId":"EL6_xyZ7SZCnVhyEmN7g5Q"},"mid":21503770,"online":true,"static":{"countryCode":"US","deviceType":"202"},"timestamp":1580098101583,"washerDryer":{"preState":"COOLING","remoteStart":"REMOTE_START_OFF","state":"END"}}}},"deviceId":"REDACTED","type":"monitoring"}
- {"data":{"state":{"reported":{"meta":{"allDeviceInfoUpdate":false,"messageId":"wPDbmf-tS52hvGkGnJmzkA"},"mid":21534086,"online":true,"static":{"countryCode":"US","deviceType":"202"},"timestamp":1580098131209,"washerDryer":{"courseDryer27inchBase":"NOT_SELECTED","downloadedCourseDryer27inchBase":"NOT_SELECTED","dryLevel":"NO_DRYLEVEL","energySaver":"ENERGYSAVER_OFF","initialTimeMinute":1,"preState":"END","state":"POWEROFF","temp":"NO_TEMP"}}}},"deviceId":"REDACTED","type":"monitoring"}
- {"data":{"state":{"reported":{"meta":{"allDeviceInfoUpdate":false,"messageId":"-0lfAebaRhiygvoVbAkSeQ"},"mid":21535109,"online":true,"static":{"countryCode":"US","deviceType":"202"},"timestamp":1580098132192,"washerDryer":{"downloadedCourseDryer27inchBase":"SUPERDRY"}}}},"deviceId":"REDACTED","type":"monitoring"}
@jmh600cbr As @sampsyo said, homebridge-wideq is focused on using the port of this library for nodejs and of course I'm watching this repository. When this library switches to the new version of LG API, I will also try to transfer these changes to the nodejs port
More progress, wish I had more time to work on this. So, the new API is using MQTT. Specifically, it's using AWS IoT MQTT service, with client certificate auth. There is an LG API endpoint that will accept a CSR in a POST and return a certificate used for client auth, along with an MQTT topic. There's another endpoint with which you can retrieve the MQTT endpoint host/port.
Still not ready to send a PR back to this project, but my fork can now manage all of the above and ultimately subscribe to an MQTT topic in response to a monitor_start
call. It's a fairly short path from there to actual device monitor functionality. Once that's done there will be a fair amount of refactoring to be done so both API versions can coexist, along with adding some unit tests. Once that's all done I should be ready to open a PR for initial API v2 support.
Again if anyone wants to help I can give you contributor access to the fork directly. Fair warning, what's there right now is very rough and messy!
I recently got an lg washer and dryer. We already had an lg dishwasher. All 3 are connected to the lg app, but only the dish washer and washer are reported by wideq. could it be related to the different API's? I'd be happy to help test.
I have 3 SmartThinQ devices (Dishwasher, Washer and Dryer). Dishwasher and Dryer are returned in the device list but Washier is, for whatever reason, is missing.
I've debugged it as far as I could and it looks like the data returned from POST to device\deviceList just doesn't contain the Washer for some reason. The washer is on the same account and works fine in SmartThinQ app.
I've seen recent mention on HA forum of LG changing their API endpoints. So, perhaps, there is another API endpoint that could possibly be used instead of device\deviceList to get the list of devices?