In development: LG SmartThinQ component

Thank you for a reply.
But I use sampsyo’s component. I constantly have troubles with it.
Do you recommend ollo69’s smartthinq_sensors component?

I have used both. Try ollo69’s.

I’m still lost. I’ve created accounts on sso.lg, developer site, and through the app. I have no clue which one this integration requires.

You need to use the app login.

Is there some magic to knowing what the app login URL is? The app, from what I see, does not share where I’m actually authenticating.

I’m clearly missing something as others have made this work, but I don’t see how they figured it out. The documentation mentions nothing about URL’s, redirects, or blank pages. It does say not to use facebook, google, etc.

I’ve figured it out. I’ll document the easy, but not obvious to me, process.

I am stuck as well. I get a wideq.core.TokenError. and don’t know how to fix it. Any ideas?

  • created an LG smarttinq user (without google login)
  • Installed the custom_component via hasc (Added sampsyo/hass-smartthinq repository)
  • pulled wideq qit in the custom_component directory and ran $ python3 example.py -c NL -l en-US
  • pasted returned url back and got wideq_state.json
  • got refresh_token from wideq_state.json and put it in configuration.yaml:
smartthinq:
    token: 3197fca03da4c0ab-redacted-0e29aedf7c200899f348d8c7
    region: NL
    language: en-US
  • after restart I get:

Error during setup of component smartthinq
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 193, in _async_setup_component
result = await asyncio.wait_for(task, SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 442, in wait_for
return fut.result()
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 69, in setup
client = wideq.Client.from_token(refresh_token, region, language)
File “/usr/local/lib/python3.7/site-packages/wideq/client.py”, line 210, in from_token
client.refresh()
File “/usr/local/lib/python3.7/site-packages/wideq/client.py”, line 192, in refresh
self._auth = self.auth.refresh()
File “/usr/local/lib/python3.7/site-packages/wideq/core.py”, line 371, in refresh
self.refresh_token)
File “/usr/local/lib/python3.7/site-packages/wideq/core.py”, line 299, in refresh_auth
raise TokenError()
wideq.core.TokenError

Tried the whole routine again same result. Am I getting the wrong token?
running Python3 example.py -c NL -l en-US again using the stored .json file results in a TokenError due to error 0102 NotLoggedInError.

Figured it out - LG does not seem to like mixing country and language

I need to control AC. That is why I use sampsyo’s component.
Finally I installed wideq with
pip3 install wideq

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting wideq
Downloading https://files.pythonhosted.org/packages/e8/ad/ed9d507097f628afec4097cc4d0ed2c8b4834274f5abe98aa470a1e767ec/wideq-1.4.0-py3-none-any.whl (65kB)
100% |████████████████████████████████| 71kB 1.1MB/s
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from wideq) (2.21.0)
Installing collected packages: wideq
Successfully installed wideq-1.4.0

But still I have the wideq.core.NotConnectedError: (‘0106’, ‘장치가 접속중이 아닙니다.’).

Copied example.py to /home/pi/.local/lib/python3.7/site-packages/wideq
Now I have wideq_state.json
Will see if it works in a day or two…

Can you post the whole exception, including the backtrace?

smartthinq: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 319, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
    self.update  # 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/climate.py", line 284, in update
    self.check_power()
  File "/config/custom_components/smartthinq/climate.py", line 253, in check_power
    power = self._ac.get_power()
  File "/usr/local/lib/python3.7/site-packages/wideq/ac.py", line 299, in get_power
    value = self._get_config('InOutInstantPower')
  File "/usr/local/lib/python3.7/site-packages/wideq/client.py", line 433, in _get_config
    key,
  File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 492, in get_device_config
    'data': '',
  File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 394, in post
    return lgedm_post(url, data, self.auth.access_token, self.session_id)
  File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 213, in lgedm_post
    raise APIError(code, message)
wideq.core.APIError: ('0111', '제품 응답 지연')

After my manual upgrade of refresh token it starts to work, but after some time I get the error again(

I installed the integration through HACS. Maybe the problem is connected with access permissions? (Lg component can not get a new refresh token) Or the component does not need it?

After recent Hassio installation I’m trying to set up smartthinq component for integrating AC. However, AC does not show up in the device list. Couldn’t see any errors in the HA debug log. In addition, when original wideq library is used, “python3 example.py ls” returns nothing. But wideq package by gladhorn successfully lists LG AC’s ID and device name.

And “python3 example.py mon ID” (with actual ID) says

NameError: name 'lgedm_post" is not defined

Any ideas how solve this problem?

2 Likes

Add the following import to the core_v2.py on line 13:

from .core import lgedm_post

Running example.py, can successfully get my device Id but then getting 404 on all subsequent requests.
For example:
Request to https://aic-service.lgthinq.com:46030/v1/rti/rtiControl
returns
{'timestamp': 1596054738389, 'status': 404, 'error': 'Not Found', 'message': 'No message available', 'path': '/v1/rti/rtiControl'}

I added the line, now I am receiving

KeyError: ‘lgedmRoot’

Suggestions?

1 Like

I found that most of API commands have to go to https://aic.lgthinq.com:46030/api, the authentication still happens at https://aic-service.lgthinq.com:46030/v1/.
Both URLs have been returned from the server but for some reason only second was used.
I made changes to use both and use session to authenticate to the first URL. Now everything is working. Trying to figure out where to post the patch.

Hello Craig.
Can you remember how you did this exactly?
I have had only one AC unit which was working fine with this component. Since yesterday I have three AC units and only the first one is showing up in HA.
Reinstalling the component did not change anything.

Thank you

Hi,
I have installed the HACS and added the integration.
Now when I am adding the integration in the HA, I am stuck at the page “SmartThinkQ LGE Sensors - Authentication” … what is the redirection URL I am supposed to use??
Please guide

I described how it worked for me previously but since then it occasionally drops one of the two units. I then try one of two things.

1.power down the unit (using the circuit breaker)
2 reboot everything, including the router

These 2 have always brought things back online

I have also disconnected lg smartthinq from Google Assistant and instead use climate in GA within HA