In development: LG SmartThinQ component

holy crap i keep hitting 1 wall after another. So i went to look at that URL to get the states you mentioned and i get this

{"model_info": {}, "gateway": {"auth_base": "https://us.m.lgaccount.com", "api_root": "https://aic.lgthinq.com:46030/api", "oauth_root": "https://us.lgeapi.com"}, "auth": {"access_token": "REDACTED", "refresh_token": "REDACTED"}, "session": "REDACTED.node_sadap_10"}

I dont get a URL in model_info.

That’s odd. Not sure how or what the code does to get that info. Either way, you can just look at that file where you found that info a little more. I believe everything that the link would have is the stuff that’s already in the file. The link simply has it formatted better but it all should be in that file that you need. Just dive into that and see what you find in terms of statuses and such.

Does anyone know how to use this with 0.88+ HA?

@bdf0506 @subzero79 @wkd8176 @fn87

See my github.

@wkd8176 I already had it working on 0.87.1 and have some specific modes for my washer.

How do I make it work for 0.88+?

I moved smartthinq_washer.py to custom_components/smartthinq and renamed it to sensor.py

However it is not loading both smartthinq component and platform.

@forums2012 Starting with .88+ custom components were changed so everything pertaining to that component needs to be moved. Here is the thread where I fought this issue. My custom component was not in the core, so it was easier for me to move from a pre-.88 structure.
Check out this link and maybe thread, does any of this sound like your issue?
https://community.home-assistant.io/t/custom-cover-is-not-working-now-but-was-in-previous-ha-versions/101255/8?u=penright

Hi, what all do i need to change to get it working n other countries? Im in India, and have an LG AC. I have got it working with sampsyo’s repository. I would like to get the fan speed control, sweep control and fast cooling mode (known as ‘himalayas cool’ in indian ACs) working as well. Thanks in advance.

any ideas why i would be getting this error - running the latest sampsyo component from github.
I’ve checked the token created in example.py and it found the device and matches exactly.

Error while setting up platform smartthinq
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/smartthinq/climate.py", line 41, in setup_platform
    client = wideq.Client.from_token(refresh_token)
  File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 570, in from_token
    client.refresh()
  File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 556, in refresh
    self._auth = self.auth.refresh()
  File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 279, in refresh
    self.refresh_token)
  File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 232, in refresh_auth
    raise TokenError()
wideq.TokenError

That error indicates that the LG servers rejected your authentication token. This might be related to the country where your account resides, or it could be worth trying to just generate a new token by authenticating again.

@samps
thanks for responding - I had this working for me before doing a rebuild - when i run the example.py it detects the device so it appears to be working OK at that level. I’ve tried a few refreshes now however still no luck.

also I have modified the wideq.py to match the Australian region

Had exactly the same problem (wideq.py modified to German account). At every restart my modified wideq.py is overwritten by the standard US one causing above error. Fixed it by commenting out the requirement line in manifest.json in custom_components/smartthinq.

Maybe give that a try too.

1 Like

yep that worked! thanks for the fix

Hi, I got an error below when I change parameters in wideq.py file for Turkish Culture.
COUNTRY = ‘TR’
LANGUAGE = ‘tr-TR’
I think it is a encoding problem.
How can I solve this.

Traceback (most recent call last):
  File "example.py", line 176, in <module>
    example(sys.argv[1:])
  File "example.py", line 162, in example
    example_command(client, args)
  File "example.py", line 139, in example_command
    ls(client)
  File "example.py", line 26, in ls
    print('{0.id}: {0.name} ({0.type.name} {0.model_id})'.format(device))
UnicodeEncodeError: 'latin-1' codec can't encode character '\u015e' in position 42: ordinal not in range(256)

Thanks for help.

Hi, I am trying to make this work here from Canada. I modified the COUNTRY to CA and LANGUAGE to en-CA in wideq.py.

I can get through the execution of example.py, authentication works, then I can copy back the URL.

Unfortunately on execution, I am still getting the “wideq.APIError: (9003, ‘세션생성실패’)” message.

How can I solve this. Thanks for help !!!

That error appears to translate to ‘Session creation failed’. Where did you modify wideq.py? In <path-to-config>/deps/lib/python3.7/site-packages ?

I am running the hassio image on a Raspberry PI and I am stuck at this step of the wideq installation:

$ python3 example.py

I get the following error

-bash: python3: command not found

Can someone help please ? I guess I need to install python or something like that but the usualy linux sudo commands do not appear to work when I am logged to the Raspberry with ssh

as you can probably tell, I am not a big expert here. Thanks

UPDATE: OK I realized I didn’t need to run example.py on the raspberry so I loaded Python in another computer and used that to get to the refresh token. After that all went well and I am now conrolling my LG AC with home assistant. Amazing work

Hi there,

I’m getting an LG AC in the next couple of weeks and looking for an integration with HA. How is the use of this component with Hassio? I read through all the posts and it seems pretty advanced before you can set it up.

Is this the only way?

Thanks!

I’ve been messing around with a fork of the custom component and the wideq library from @wkd8176 . I was able to fix 2 big issues I had with the component:

  1. Washer and dryer entities were lost when home assistant was restarted if the washer/dryer were not on.
  2. Instead of spamming the logs with not being able to connect to the washer/dryer after a cycle was done and the machine was no longer reachable, it now simply gets set to an ‘Unavailable’ state and will become ‘available’ again when it gets turned on for the next use.

I plan on cleaning up the diff and opening up a PR, right now it has a lot of extra code (mostly adding washer/dryer states) to make it work with my LG Washer and Dryer. My dryer is always reachable so I didn’t modify the component to set the dryer to unavailable.

If anyone wants to try it out the code is available here:

1 Like

Hi karsie, I decided to go with the Broadlink climate control since I have one AC unit that can not support Smart ThinQ and was not able to make the component work in Hass.io.
Setup was easy and it does not rely on web services. All is done internally so it is very responsive.

Hi, folks—small update here. First, I’ve put wideq on PyPI:

which should make installation a little less error prone. I have also added configuration options for the language & country parameters, which should obviate all the hacking people have needed to do in non-US locales. You can just put this in your configuration YAML now, for example:

country: KR
language: ko-KR

See the updated instructions in the README. Good luck!

3 Likes