In development: LG SmartThinQ component

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

Hi,
Same 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.

  1. Note that the latest wideq does not need code changes to work in different countries. (See my most recent post, above.)
  2. To fix this Python problem, you may want to configure your system to use a UTF-8 locale. The google terms python utf8 locale might help.

Hi Adrian @samps, thanks so much for your amazing work here. Brilliant!

did you ever get a chance to try out @smileyvie Walters ideas on fixing the ability to use both the App and the HA module for control of the AC?

My problem right now is that if wideq is being used, I can’t set temps through LG Alexa integration, likely due to the known issue of conflict between the LG App and HA.

Sounds like Walter had a good idea- did you manage to test it?

Would also love some guidance on how to expose fan speed for LG heat pumps. HA and python newbie here.

Thanks!!
Yeang

It does seem cool! I have not tried it out yet, though—I don’t have the time to do an implementation from scratch, and it would be awesome to have help from anyone who knows Python.

Anyone running HA without Hassio on version 0.88 or higher, with an EU Washer? :grimacing: I’m trying to get this to work 0.94.4.

I’ve installed wkd8176/hass-smartthinq into custom_components
and I’ve gotten far enough that I’m getting the following in the logs:

[custom_components.smartthinq] Creating new LGE component,

I’ve tried outputting the device id of this component above :point_up:, and it looks correct

My folder structure is built like this:

~/.homeassistant/custom_components $ ls ./*

  ./sensor:
    smartthinq_washer.py

  ./smartthinq:
    __init__.py  __init__.py.save  
    __pycache__  climate.py  fan.py  
    manifest.json  sensor.py  services.yaml

  ./volkswagencarnet:
    __init__.py  __pycache__  binary_sensor.py  
    device_tracker.py  lock.py  sensor.py  switch.py

Wideq is installed in /.homeassistant/wideq from GitHub - wkd8176/wideq: reverse-engineered client for the LG SmartThinQ API

I’ve tried borrowing @knackrack615s smartthinq_washer sensor, but when I add it as a sensor in configuration.yaml I’m getting “integration smartthinq_washer not found when trying to verify its sensor platform.” during configuration validation.

In configuration.yaml

  - platform: smartthinq_washer
    name: Washing Machine
    mac: 20:3d:xx:xx:20:bf

When trying to debug inside the virtualenv on my Hassbian install, it seems everything related to the wideq library works, but I’m suspecting some compatibility issues with breaking changes in HA makes it so difficult for me to get any info inside HA at all?

I’ve of course made sure the washer is running and connected to WiFi while debugging. And the token seems valid. No issues in the logs, but I have no way of accessing any data from the washer. Any ideas how I can get access to it or debug further?

Thanks in advance, great job all of you. Hope I can help merge everything into an official component one day or weekend in the future!

EDIT: I got it to work after some changes, summarizing quickly (at least for now)

  1. Made sure my folder structure was compliant to the new custom_components setup
  2. Added some extra logging, to figure out where it broke previously
  3. Added try/catch blocks to sensor.py from @knackrack615 to avoid issuses with non-supported on/off-data (added fallback to “off” if WasherStatus didn’t have the correct attribute).

Would be great if you could share what you did to make it work, so others can benefit from your findings.

I’m not able to get past the configuration checker. I have cloned @wkd8176 's repo, and put the custom component subfolder into my custom_components folder. I’m running HassIO 0.94.4, with the custom deps add on.

The add on config looks like this:

{
  "pypi": [
    "https://github.com/simlaf/wideq/archive/master.zip#wideq"
  ],
  "apk": []
}

What am I missing? I feel like it’s something obvious. I’m trying to get my washer and dryer connected.

Can you provide more information? What do you mean by not being able to get past the configuration checker? Are there any errors or logs? Did you intend to use the original wideq library and not wkd8176's fork (“https://github.com/wkd8176/wideq/archive/master.zip#wideq”)?

@fahr The configuration checker spinner never goes away. If I look in the console, I can see it’s an error 500, and the only information is the server got itself in trouble.

I want to use wkd8176’s fork, as I’ll be using it for the washer and dryer. I used the wideq library on another pi to get the refresh token, and it was able to detect the appliances no problem.

My sensors.yaml looks like this:

- platform: smartthinq
  name: Washer
  mac: 2c:2b:f9:e4:56:b9

- platform: smartthinq
  name: Dryer
  mac: 74:40:be:09:77:d1

and my configuration.yaml looks like this:

# LG SmartThinQ integration
smartthinq:
  token: 9ee8266c9eabf3b0de774335f4cb1d09bf7e0ae294502aabe5334e87c9bfc0cf28d79b1db314b498b83b0c8c7fd68b6c

(note that’s not the actual token, but it’s in the same format)

It’s hard to say without more information. Is there a stacktrace in the logs? Did you modify the wideq library to point to your country?

It looks like you are using a mix of simlaf's wideq library and wkd8176's addon. I’m not sure how much they’ve diverged but it might be worthwhile to use wkd8176's fork of the wideq library: https://github.com/wkd8176/wideq

It’s hard to say without knowing exactly which version of the wideq library and the hass-smarthinq component you have installed. Also any logs or stacktraces would be helpful in debugging.

I had to create my own forks to get this to work with my washer/dryer. https://github.com/boralyl/hass-smartthinq / https://github.com/boralyl/wideq

I made my own fork of @wkd8176’s wideq library, in order to change the country code to Canada, but I’m still running into trouble. So my custom deps deployment config looks like this:

{
  "pypi": [
    "https://github.com/jptrsn/wideq/archive/master.zip#wideq"
  ],
  "apk": []
}

Looking at logs, I’m seeing it mention there’s no attribute STATE_WASHER_APCOURSE_COTTON but looking at wideq.py I’ve made sure that attribute exists (it’s on line 257)

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 216, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 115, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 31, in post
    errors = await async_check_ha_config_file(request.app['hass'])
  File "/usr/src/homeassistant/homeassistant/config.py", line 747, in async_check_ha_config_file
    res = await check_ha_config_file(hass)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/scripts/check_config.py", line 403, in check_ha_config_file
    platform = p_integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 139, in get_platform
    "{}.{}".format(self.pkg_path, platform_name)
  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/sensor.py", line 61, in <module>
    'COTTON': wideq.STATE_WASHER_APCOURSE_COTTON,
AttributeError: module 'wideq' has no attribute 'STATE_WASHER_APCOURSE_COTTON'