In development: LG SmartThinQ component

I have the same issue too, recently brought an LG - F4V508WS WiFi-enabled washer, no device is returned in the wideq_state.json file, spent hours trying different things but had to accept defeat for the time being when I had noticed a few posts raised on GitHub stating this same issue.

{“model_info”: {}, “gateway”: {“auth_base”: “https://gb.m.lgaccount.com”, “api_root”: “https://eic.lgthinq.com:46030/api”, “oauth_root”: “https://gb.lgeapi.com”, “country”: “GB”, “language”: “en-GB”}, “auth”: {“access_token”: “REDACTED”, “refresh_token”: “REDACTED”}, “session”: “REDACTED.nodes_sadap_10”, “country”: “GB”, “language”: “en-GB”}

Also there are no errors thrown in the logs in HA, setup all looks good and can see the washer within the Smartthinq mobile app.

I recently updated HA and Hass.io, now I’m getting:

Error loading custom_components.smartthinq. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 346, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/smartthinq/__init__.py", line 5, in <module>
    import wideq
ModuleNotFoundError: No module named 'wideq'

Now I tried to install wideq again using “Custom deps deployment” but I get the following error:

[Info] Remove old deps
[Info] Install pypi modules into deps
  Missing build requirements in pyproject.toml for https://github.com/sampsyo/wideq/archive/master.zip#wideq==0.0.1.
  This version of pip does not implement PEP 517 so it cannot build a wheel without 'setuptools' and 'wheel'.
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-7358rc87/
[Error] Can't install PyPI packages!
Collecting https://github.com/sampsyo/wideq/archive/master.zip#wideq==0.0.1
  Downloading https://github.com/sampsyo/wideq/archive/master.zip
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/local/lib/python3.6/tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-7358rc87/setup.py'
    
    ----------------------------------------

Anyone with similar problems?

For me also the example.py wasn’t working, and somehow i could not login to the URL provided by WideQ. However, i was logged in to the app. Eventually i ended up getting the right combination of country and language (for me it was NL + en-US) to succesfully log in. This is the most important part of it.

I am now seeing my dryer succesfully;

> python3 example.py -c NL -l en-us
[UUID]: DROGER (DRYER RC90U2_WW)

So i am getting somewhere. In the meantime i have opened up a pull request to tidy up the code a bit, but it is my first Python3 experience.

I am going to try and add the dryer component; but i have never built a HA component so i first have to get it to work locally before i can submit something.

Hello,
Has anyone managed to get LG SmartThinQ custom component to work on a HASSIO image on a raspberry Pi.

This is for my LG HVAC

I’ve been following this thread since last year with no luck. Decided to give it a go again, but still no luck. :frowning_face:

Can anyone please give me any advice and what steps to take? (If it’s possible)
I have copied all contents from " hass-smartthinq " GITHUB and the " wideq " GITHUB to their relevant folders:

config\custom_components\smartthinq
config\custom_components\wideq

I have also followed the instructions (as best I could) and successfully got my token.

I have added the configuration.yaml line also:

Copy to clipboard

smartthinq:
  token: 34f0eeb287a16751a8f39479037b28......etc
  region: AU
  language: en-US

I receive the following errors:

image

Log Details (ERROR)
Thu Oct 17 2019 19:03:05 GMT+1100 (Australian Eastern Daylight Time)
Error loading custom_components.smartthinq. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 346, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/smartthinq/__init__.py", line 5, in <module>
    import wideq
ModuleNotFoundError: No module named 'wideq'

Looks like it can’t find the “wideq” module, perhaps I have not copied the components into the correct folders?

Any assistance will be greatly appreciated

Thanks in advance

Paul

I had to put wideq as subfolder of smartthinq and that solved the errors.
But now I missed the whole point and noticed that it doesn’t have washer/dryer integration

I ran into the same problems. I’ve switched to https://github.com/GuGu927/hass-smartthinq
The manifest should automatically install the proper wideq version. You will have to put in a bit of work to translate the Korean characters in both the custom component and wideq, but it worked fine for me after with a lg washer.

Also add this to init.py in the wideq folder to avoid ssl errors:

requests.packages.urllib3.disable_warnings()
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += 'HIGH:!DH:!aNULL'
try:
    requests.packages.urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST += 'HIGH:!DH:!aNULL'
except AttributeError:
    # no pyopenssl support used / needed / available
    pass

@bdf0506, did you ever experience issue where your wideq module is not correctly loaded?
I am using hassio and and I get following error:

File "/config/custom_components/smartthinq/sensor.py", line 55, in <module>
    'OFF': wideq.STATE_WASHER_OFF,
AttributeError: module 'wideq' has no attribute 'STATE_WASHER_OFF'

Makes me think that incorrect version of wideq is used, even though I changed REQUIREMENTS to match your github path

I keep running into this error:

Error during setup of component smartthinq
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 171, in _async_setup_component
component.setup, hass, processed_config # type: ignore
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/smartthinq/init.py”, line 67, in setup
client = wideq.Client.from_token(refresh_token, region, language)
TypeError: from_token() takes 2 positional arguments but 4 were given

Anyone have ideas?

FYI if you had the smartthinq custom component working for some time then recently are getting errors setting up the platform, you will need to clone the repo and run the example.py file as mentioned in the README.

What was happening is when I logged into lg, it redirected me to another page asking me to agree to their privacy policy. After I checked that box and hit submit it then redirected me to the url with the token in it. I restarted home assistant and my washer and dryer then showed up again.

Funny to see that more and more forks are being made but nobody is actually trying to contribute back to the original repo. I only have a dryer from LG and was missing that functionality. Since i wanted to learn Python a bit and how it interacts with HA I’ve added a very basic implementation of it; and opened up a pull request.

My Pull request contains a lot of refactoring, basically seperating LGDevice, LGDishWasherDevice etc to seperate python modules. It is not done yet, but at least it now allows me to discover my dryer.

I will integrate the changes from the GuGu927 branch to enrich my dryer implementation and add the washer implementation. I hope the original author will then merge it so his code gets access to multiple new devices.

3 Likes

I tried to do this for a little while but the states are very different that are reported by different models of washers and dryers. It would take much more effort to make it more generic and work with multiple models. Most forks (including mine) simply hardcode the states to those reported by the washer/dryer the fork owner uses.

I did make a bunch of PRs (that were merged) to the wideq repo in preparation for adding washer/dryer support to the hass-smartthinq custom component, but ended up taking on other projects. It’s hard to get motivated since my fork “works for me”.

Thank you for taking the time and making the effort!

Just picked up a SmartThinQ fridge last night and also have a heat pump (ductless mini split) unit in the house with three (two different) head units. I don’t have the SmartThinQ modules for the mini split yet as I have been waiting to see how this component matures, but now that I have the fridge I’m more interested.

I’m seeing a few different repos here, mainly @samps and @wkd8176. Also noting there is an issue with different models and locales with the LG API. I’m a complete Python noob, but would it be possible to merge to a single repo with all the different / known models and configurations and just continue to add to and build from the single source? I see @fahr’s note re: hard coding for your own device and it just works, but surely with a small effort those hard coded items could be turned into variables (as appropriate) for people to add their own credentials / configurations.

Where is the best place to start for someone who doesn’t know Python and only has a fridge (and lives in Canada … apparently that matters too)?

would it be possible to merge to a single repo with all the different / known models and configurations and just continue to add to and build from the single source?

Yes, that’s exactly what I’m hoping for as the originator of this package. The plan relies, however, on the authors of the code for different devices doing two things: (1) being willing to contribute their modifications back to the original repository, and (2) putting in the effort to make the code clean, readable, and testable so it’s suitable for continued evolution.

1 Like

Started getting this error…

"The following components and platforms could not be set up:

  • smartthinq.sensor

Please check your config."

This is my config…

smartthinq:
token: xxx
region: TH
language: th-TH

It’s working but only picking up 1 of 2 AC units. Any ideas?

1 Like

Been poking around a lot here and am running into issues getting my LG Washing machine to show up using example.py.

I have a WM3700HVA US Model Washing Machine but when I run example.py with wideq after authenticating it comes up completely blank. No errors or anything, just like it can’t find the device at all…

I noticed that the wideq repository is forked 71 times, and have tried numerous repos but cannot get it to show up at all. What am I missing here? Any assistance? There are two “issues” that have been created on the topmost wideq repo in regard to adding washer support and other people running into this problem.

Thanks

2 Likes

Is it ethical to scrape the forks and merge the changes back upstream after testing?

Also, I would really love to see this component be made compatible with HACS.

2 Likes

Hi, same behavior here. only one AC showing (Firts One), with 3 AC units integrated on the APP.
Anyone knows how to get this right?

1 Like

Hi seems that something changed. I got the below error:

python3 example.py -c US -l en-US
Traceback (most recent call last):
File “example.py”, line 1, in
import wideq
File “/home/homeassistant/wideq/wideq/init.py”, line 4, in
from .client import * # noqa
File “/home/homeassistant/wideq/wideq/client.py”, line 422
self.model: ModelInfo = client.model_info(device)
^
SyntaxError: invalid syntax

That indicates that your version of Python is too old. You will need 3.6 or later.

Hi thanks for the prompt reply!