In development: LG SmartThinQ component

Yep same error.

Some other feedback:

I’m running HA locally in a container while I get used to it and set things up, this means lots of restarting. The SmartThinq integration connected the first time I gave it the refresh token, but never again… until I ran example.py again this evening.

Same refresh token; I never changed it in my config, but now it’s connected. Just had to restart the server to re-connect.

Also something to note, it seems for at least their mirror AC collection, when you turn it off, the wifi also shuts down. Not a great user experience.

Dang, that’s too bad. My heat pumps don’t do that, fortunately—“off” still leaves the WiFi connected.

OK, I’ve fixed that problem:

Here’s something else.
After some period of time, I’m seeing this in the logs:

Traceback (most recent call last):
File "/usr/src/app/homeassistant/core.py", line 1115, in _event_to_service_call
  await service_handler.func(service_call)
File "/usr/src/app/homeassistant/components/climate/__init__.py", line 439, in async_on_off_service
  await climate.async_turn_on()
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
  result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/climate/smartthinq.py", line 164, in turn_on
  self._ac.set_on(True)
File "/wideq/wideq.py", line 874, in set_on
  self._set_control('Operation', op_value)
File "/wideq/wideq.py", line 706, in _set_control
  {key: value},
File "/wideq/wideq.py", line 357, in set_device_controls
  'data': '',
File "/wideq/wideq.py", line 281, in post
  return lgedm_post(url, data, self.auth.access_token, self.session_id)
File "/wideq/wideq.py", line 122, in lgedm_post
  raise APIError(code, message)
wideq.APIError: ('0106', '장치가 접속중이 아닙니다.')

And the units no longer respond. To note, I have the LG Mirrior mini-splits.

Ok one more datapoint; we’ll get that track back when the unit (or all units) are off and non-responding. Once I turned the unit back on, I could control it again and the trace no longer occurred.

Hi,

I own an LG washer/dryer that I currently control through SmartThinQ app.
For now I just want to be able to start and stop a given wash cycle and maybe have HA notify me when it ends.

Will this component let me do it?

Thanks
Claudio.

It doesn’t have washer/dryer support yet, except for in the fork that’s been mentioned a few times in the thread above,

I try to make this working for my refrigerator.
There is no platform for refrigerator, so i changed the smartthinq.py, but I can’t set up this platform.

Setup code is below

def setup(hass, config):  

import wideq

refresh_token = config.get('token')
client = wideq.Client.from_token(refresh_token)

return True

And the error is

Error during setup of component refrigerator
Traceback (most recent call last):
File "/usr/src/app/homeassistant/setup.py", line 148, in _async_setup_component
component.setup, hass, processed_config)  # type: ignore
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/refrigerator.py", line 63, in setup
client = wideq.Client.from_token(refresh_token)
File "/config/wideq/wideq.py", line 598, in from_token
client.refresh()
File "/config/wideq/wideq.py", line 584, in refresh
self._auth = self.auth.refresh()
File "/config/wideq/wideq.py", line 306, in refresh
self.refresh_token)
File "/config/wideq/wideq.py", line 244, in refresh_auth
refresh_token)
TypeError: must be str, not NoneType

If i change the token to str type, it occures token error.

I also use ac components(smartthinq for climate), it works perfect. I don’t know what’s different.

How’s the component coming along?

Checked your fork @simlaf and by the replies here it looks really promising. Just bought a LG F4J7TY2W Washer/Dryer Combo that I will use to check your fork.

Will share my results here and will be happy to help anyone with the setup if I succeed.

Hi Guys, I’m also receiving the error when i paste in my redirect URL.
The korean error message translates to “session creation failed”

edit: when i switched my account to a US account the example.py script worked fine - i think the issue is linked using a different server for authentication? (i’m in Australia so it uses oauth2_backend_url=https://kr.lgeapi.com/)

Is there a way to fix this? i cant seem to register my product correctly on the US account

Traceback (most recent call last):
  File "example.py", line 180, in <module>
    example(sys.argv[1:])
  File "example.py", line 166, in example
    example_command(client, args)
  File "example.py", line 146, in example_command
    func(client, *args[1:])
  File "example.py", line 34, in mon
    device = client.get_device(device_id)
  File "/srv/homeassistant/wideq/wideq.py", line 475, in get_device
    for device in self.devices:
  File "/srv/homeassistant/wideq/wideq.py", line 467, in devices
    self._devices = self.session.get_devices()
  File "/srv/homeassistant/wideq/wideq.py", line 458, in session
    self._session, self._devices = self.auth.start_session()
  File "/srv/homeassistant/wideq/wideq.py", line 256, in start_session
    session_info = login(self.gateway.api_root, self.access_token)
  File "/srv/homeassistant/wideq/wideq.py", line 179, in login
    return lgedm_post(url, data)
  File "/srv/homeassistant/wideq/wideq.py", line 124, in lgedm_post
    raise APIError(code, message)
wideq.APIError: (9003, '세션생성실패')
1 Like

more testing indicates that there is a bug for non-US users.
If i register my device against a US account I can get the refresh token however when I register it against my Australian account the session creation fails.

The challenge is that the device only works properly when registered against my Australia based account, when I register against the US, the smart thinq app cannot connect to the device

Is anyone else outside of US/Americas facing this issue?

@sharkpunch I edited COUNTRY and LANGUAGE in the first part of the wideq.py file to (I live, and have registered in Denmark; you can see in the app, I have English DK registered):

GATEWAY_URL = 'https://kic.lgthinq.com:46030/api/common/gatewayUriList'
APP_KEY = 'wideq'
SECURITY_KEY = 'nuts_securitykey'
DATA_ROOT = 'lgedmRoot'
COUNTRY = 'DK'
LANGUAGE = 'en-DK'
SVC_CODE = 'SVC202'
CLIENT_ID = 'LGAO221A02'
OAUTH_SECRET_KEY = 'c053c2a6ddeb7ad97cb0eed0dcb31cf8'
OAUTH_CLIENT_KEY = 'LGAO221A02'
DATE_FORMAT = '%a, %d %b %Y %H:%M:%S +0000'

I can’t remember if this changed the link that came out to show country=DK (or AU for you, I guess) somewhere in the url. If not, then I changed this manually, and it worked.

2 Likes

Any plans to officially integrate the component into Home Assistant?

thanks! that worked perfectly

Is this component planned to include more type of SmartThinQ devices?

Was able to pull device status for my LG F4J7TY2W washer/dryer @simlaf :vulcan_salute: I’m based in Norway so had to set locales in wideq.py to “NO” and “no-NO” which got me a korean OAuth process - but it worked:

Polling...
- State: @WM_STATE_INITIAL_W
- Remain_Time_H: 0
- Remain_Time_H: @WM_STATE_POWER_OFF_W
- Remain_Time_M: 54
- Remain_Time_M: 54

Hope this will be possible to install with Hassio soon. As far as I can understand, we need to have WideQ as a Pypi package? Outputs below from my home-assistant.log.

home-assistant.log

2018-10-29 23:02:59 INFO (SyncWorker_17) [homeassistant.util.package] Attempting install of wideq
2018-10-29 23:03:12 ERROR (SyncWorker_17) [homeassistant.util.package] Unable to install package wideq: Could not find a version that satisfies the requirement wideq (from versions: )
No matching distribution found for wideq
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
2018-10-29 23:03:12 ERROR (MainThread) [homeassistant.requirements] Not initializing climate.smartthinq because could not install requirement wideq
2018-10-29 23:03:12 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform climate.smartthinq: Could not install all requirements.
2018-10-29 23:03:12 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event config_entry_discovered[L]>
2018-10-29 23:03:12 INFO (MainThread) [homeassistant.loader] Loaded persistent_notification from homeassistant.components.persistent_notification
2018-10-29 23:03:12 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could$

  • climate.smartthinq

Hey Guys.
I developed AC, REFREGERATOR, WASHER&DRYER, TUMBLE DRYER component.
I made it for KOREAN ONLY, so if you want to use, you may change some code for your country.

I don’t know how to link github with block, so I just link url

https://github.com/wkd8176/hass-smartthinq
https://github.com/wkd8176/wideq




Component not found: smartthinq

Sorry I fix the readme, please try again
You just need to put everythin in your config folder