In development: LG SmartThinQ component


#43

I can only talk about my AC devices, but yes, they must connect to the cloud for control. They join my Wi-Fi network to talk to LG servers; my reverse engineering work works the same way as the mobile app, which also talks to LG servers, which in turn send commands back to the device.

Another fun project might be to analyze the traffic between the LG device and the server—maybe you can mimic and then replace the server with a local controller. Seems hard, but perhaps possible!


#44

Hah… In that case I’ll pass in buying LG appliances. It will be very hard to look for large appliances that can communicate locally when it comes to failing gracefully, so I might as well forget about it.

Thanks.


#45

Hello,
I’m new to HA and found this post here. Great work !!!
I found a strange behaviour by using wideq in HA.
If a AC device is only monitored it is possible to control it also with the original App.
But if it is turned on or any setting is changed, after it is around 20 to 60 Minutes blockt for using it with the original app. I tryed also with 2 smart phones if it is the same by using the original app. The result was as long as the device is opend for contolling it is blocked for other users that are connected. After the device in the app is closed and you are in the app start screen everybody can take control.
Maybe there is something missing in the communication in wideq that after changing a setting the device is released in a way that others can also control it and don’t stay in the used state.
I tryed to look into the code and also tryed to record the communication but I did not succeed.

Greetings
Walter


#46

Interesting! I have seen something similar occasionally, where controlling the device on one machine prevents contacting it with another machine. But I’m not sure what else to do—we aren’t keeping the connection open, except to monitor the device’s status. Some more investigation is probably required.


#47

It seems that if the device list is shown in the App that the monitoring is active and if the device is opend in the app an additionally status is send to the api server.
you can see the item deviceState = ‘E’ as long as the app is displaying the device list. If the device is selected the item deviceState changes to ‘U’ and back to ‘E’ is closed.
It seems that at this time a statusupdate is send that is missing in wideq.
In the js files from the zip file from appModuleUri in the device json is at function goBackPage a function call removeControlPermission(). Unfortunally the function itself is not included in any file in the zip.

I try again to sniff the traffic, if I have success and see the missing link I will provide the info here :wink:


#48

Great idea! Any chance to make accessible the homebot wifi as well, including the history maps and the access to the surveillance camera on board?


#49

Hello,

I found the missing link to make it possible to control the HVAC from HA and the APP.
This solves the issue that the device stay in state used after send a command or request a state with wideq.

There are 2 ways:
First way:
Add 'isControlFree': 'Y', to the SET and GET calls after data in functions set_device_controls and get_device_config

Second way:
Call two times:
API_URI + 'rti/delControlPermission' with Payload: {"deviceid": "your_device_id"}
and immedetially after call start monitoring.
This way to delete the control permission of the own session have the advantage to change different settings in different calls.
I forgot to call one time start monitoring after and my HVAC was beeping every second until I did a hardreset by switching the fuse off and on. :wink:

Please be carefull - I was only able to test it on my AC device here in Austria. Maybe other types or other firmware versions it can be different.

One additionally hint is to cover each function call in smartthing.py with try: except with restarting the monitoring to catch timeouts or errors device in use and so on.

Regards Walter


#50

Very cool! Thank you for looking into it! I like the first solution quite a bit—if it works, that, would be a simple change that would cleanly address the problem. Would you mind opening a pull request on GitHub and I’ll try it out on my devices?


#51

Hi
I’ve installed wideq, etc and changed COUNTRY to “SP” and LANGUAGE to “es-SP” and obtain the URL

https://us.m.lgaccount.com/login/sign_in?authSvr=oauth2&svcCode=SVC202&language=sp-SP&client_id=LGAO221A02&country=SP&division=ha&grant_type=password

but when tried lo log in … appears an error to obtain the json file :frowning:

I’ve just created a new account in USA server, tried with several browsers but the problem remains :frowning:

It seems very strange because i’´s suggesting that there’s no network connection but, as you can see, I can surf without any problem but not from that URL :frowning:

Thank you in advance for your help


#52

I’ve added fan speed on my fork. Haven’t had time to figure out how to set the existing speed when the unit starts. I’ve never used python so sorry if it’s not A1 code!

For those that want to give it a go clone my repo:

I’ll do a PR once I sort out the existing fan speed issue (or someone chips in with a fix :slight_smile: )


#53

Solved problem using

COUNTRY= ES
and
LANGUAGE=es-ES

but the component doesn’t work in HA as I explain here: It can’t find the WIDEQ :frowning:

Thank you in advance for your help


#54

Same issue with IFTTT here in the US. I too would be wiling to help. I have a LG washer Model: WT7200CW


#55

I’ve got my SmartThinQ account tied to my google account and the URL which Wideq sends me to seems to not like it.

I get a page not found when I authenticate with google and when I past that URL into the example.py I get the following:

Traceback (most recent call last):
File "example.py", line 177, in <module>
example(sys.argv[1:])
File "example.py", line 163, in example
example_command(client, args)
File "example.py", line 140, in example_command
ls(client)
File "example.py", line 25, in ls
for device in client.devices:
File "C:\Users\Dazz\wideq\wideq.py", line 474, in devices
self._devices = self.session.get_devices()
File "C:\Users\Dazz\wideq\wideq.py", line 465, in session
self._session, self._devices = self.auth.start_session()
File "C:\Users\Dazz\wideq\wideq.py", line 257, in start_session
return Session(self, session_id), as_list(session_info['item']) 
KeyError: 'item'

I’ve tried different combinations of the URL parameters and I’m able to get different responses, but none of them work with this process, nor do any of the refresh or bearer tokens from google work with the HA integration.


#56

Hmm! What does the URL you’re redirected to look like? (You’ll probably want to redact the actual tokens, but seeing the format of the URL would be helpful.)


#57

This is the URL I’m sent to:

https://us.m.lgaccount.com/login/iabClose/thirdpartylogin?third_party_type=GGL&front_url=https://us.m.lgaccount.com/login/sign_in?country=US&language=en-US&svcCode=SVC202&authSvr=oauth2&client_id=LGAO221A02&onyx_feature=N&division=ha&show_select_country=N&show_add_services=N&oauthTokenExpiredFlag=N&globalFacebook=false&globalGoogle=false&os_type=PC

It just comes up with a “Page not found”. No tokens in it. I have to remove the “division” and other url params to get anything approaching a bearer or refresh token.


#58

Hmm; that indeed doesn’t look right. Is there any chance you can associate a password with your account and try logging in that way?


#59

Just for shits and giggles, I created a new account with a different email address but did not associate any devices.

Even though it said “Page not Found”, I got this URL instead (of course I have redacted and changed the tokens):

https://us.m.lgaccount.com/login/iabClose?access_token=12312314f66986REDACTEDbc3f2310863e3e611cba75ed8364aa730a48622f&refresh_token=123423415c14c71111ee0e0REDACTED3b5a72de49600d9a323b&oauth2_backend_url=https://us.lgeapi.com/

Running the example.py sill gives an error.


#60

Huh! Exactly the same error traceback? Sounds like it could just be a coincidence. I may have to look into it a little more deeply.


#61

Ok; after adding a device it works.
Looks like the python does not like empty collections.

Still does not work with a google account integration


#62

Aha, got it. Was it the same error before (with the same traceback)? If so, we should detect that and just report zero devices.