In development: LG SmartThinQ component

Could be because of Cache issues. Try deleting _pycache_ & restarting HA

Hello, you do not need to generate a new token from HA, try using the URL you get from your JSON dump

Also you do not need to put the token in quotes

Any plans to officially port the component to HA?

Would really appreciate your help. I am getting socket.gaierror

2018-12-20 02:36:57 ERROR (MainThread) [homeassistant.setup] Error during setup of component smartthinq
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 301, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x728018f0>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='us.lgeapi.com', port=443): Max retries exceeded with url: /oauth2/token (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x728018f0>: Failed to establish a new connection: [Errno -3] Try again',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/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/smartthinq/__init__.py", line 39, in setup
    client = wideq.Client.from_token(refresh_token)
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 653, in from_token
    client.refresh()
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 639, in refresh
    self._auth = self.auth.refresh()
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 357, in refresh
    self.refresh_token)
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 306, in refresh_auth
    res = requests.post(token_url, data=data, headers=headers)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='us.lgeapi.com', port=443): Max retries exceeded with url: /oauth2/token (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x728018f0>: Failed to establish a new connection: [Errno -3] Try again',))
2018-12-20 02:36:58 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of sensor.smartthinq_washer. Setup failed for dependencies: smartthinq
2018-12-20 02:36:58 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.smartthinq_washer: Could not set up all dependencies.

Finally got this working!
Nice.
Getting timeout errors here and there though.

Also state is showing UNKOWN. Not updating. what do I change to fix that?

Thanks.

How do I fine tune the States for my washer?
I mean I see some differences in your json and my json.
My machine is a washer/dryer combo so would love to add all functionality.
Thanks.

Hi
I have LG F4J7TY1W washer

did all steps from here https://github.com/knackrack615/wideq-homeassistant
copied example.py from https://github.com/wkd8176/wideq to /deps/lib/python3.6/site-packages/

but if i execute python3 example.py, i got error “ModuleNotFoundErrorL : no module named requests”

Could someone please guide, what am I missing here. Thanks

ok I was missing pip3 install requests

now the link is not responding on Sign In :frowning:

Really love this module and what I can do with it.

I guess we need a way to convert the API State json to code or to be used by the code in wideq and the sensors. Handling the problem with sensor updateing takeing to long when the washer is off is antoher thing that need to be looked at before this goes in to HASS. I will try to look in to this during the holidays.

This is my current setup for my FH6F9BDSK2 with a light as a progressbar and some custom Lovelace entity solutions:
image

Thanks everyone contributing to this!

Wow. That’s amazing.
Would love if you could share how you got about adapting it to your own needs.

Also when machine kept off for a day or two, the component got disconnected and all sensors are unavailable now. How are you tackling this?

I have the component working however my model offers certain other options/states which I want to customize.

Thanks in anticipation!

If you’re getting a Page not found page, don’t worry just copy paste the link it has the refresh and access token required for this to work.

Not done much. Used Example.py to extract the states for machine and replace most of the enum data in wideq. Then I updated the sensor file to match and worked through all settings manually to see where it still failed. Also remove some data that i didn’t need to make the process faster.

The rest is template sensors.

Haven’t had the issue with the sensor yet, only wideq. Will see during Christmas if it’s a problem.

Awesome. Thanks a lot.
What repo did you use finally and could you share your config?
How did you nest the various sensors under the main washer sensor?
Also my sensor.washer always has a state of -/UNKOWN. Same for you?

Used wdk’s repo but i think that knackrack615’s repo are better as it fixed the apcourse för non Korean machine.

I got unknow as the status for my washer but it really doesn’t matters as I only use template sensors on the attributes. Use this to get started:

@knackrack615 @wkd8176 @fn87
Would appreciate if someone can help.

I am able to connect to the API using my macbook however getting New Connection Error: Max retries exceeded again and again on Hassio
Have restarted HA quite a few times now.
Would appreciate any help.
Here’s the error from log: https://pastebin.com/GbSjSUuN

018-12-24 17:09:38 INFO (SyncWorker_7) [custom_components.smartthinq] Creating new LGE component
2018-12-24 17:09:48 WARNING (MainThread) [homeassistant.setup] Setup of smartthinq is taking over 10 seconds.
2018-12-24 17:11:20 DEBUG (SyncWorker_6) [custom_components.sensor.smartthinq_washer] Creating new LGE Washer
2018-12-24 17:11:22 WARNING (MainThread) [homeassistant.components.sensor] Setup of platform smartthinq_washer is taking over 10 seconds.
2018-12-24 17:11:37 INFO (SyncWorker_6) [custom_components.sensor.smartthinq_washer] Updating WASHER.
2018-12-24 17:11:37 INFO (SyncWorker_6) [custom_components.sensor.smartthinq_washer] Polling...
2018-12-24 17:11:42 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform smartthinq_washer
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 301, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x719d06f0>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='aic.lgthinq.com', port=46030): Max retries exceeded with url: /api/rti/rtiMon (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x719d06f0>: Failed to establish a new connection: [Errno -3] Try again',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  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/sensor/smartthinq_washer.py", line 139, in setup_platform
    washer_entity = LGEWASHERDEVICE(client, device)
  File "/config/custom_components/sensor/smartthinq_washer.py", line 165, in __init__
    self.update()
  File "/config/custom_components/sensor/smartthinq_washer.py", line 347, in update
    state = self._washer.poll()
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 1048, in poll
    data = self.mon.poll()
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 518, in poll
    self.work_id = self.session.monitor_start(self.device_id)
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 416, in monitor_start
    'workId': gen_uuid(),
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 395, in post
    return lgedm_post(url, data, self.auth.access_token, self.session_id)
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 222, in lgedm_post
    res = requests.post(url, json={DATA_ROOT: data}, headers=headers)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='aic.lgthinq.com', port=46030): Max retries exceeded with url: /api/rti/rtiMon (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x719d06f0>: Failed to establish a new connection: [Errno -3] Try again',))

It seems like the LGE component is created, then LGE washer component is created, then I see POLLING in logger, and then this error fails the setup of smartthinq_washer

Here’s the custom component: https://github.com/knackrack615/wideq-homeassistant

I haven’t experienced that. Looks like you fail on connecting to the api.

I do not even use the same address as you do. Are you sure that the address are correct?

gaierror: [Errno -3] Temporary failure in name resolution

I do have 10 second interval errors but thats excpected as my washer is off.

I tried using @wkd8176’s repo as well with only modification of country and language.
Still no luck.
Max retry errors.
sometimes it shows api/member/login
sometimes rti/rtiMon

Shows different failure url each time

Got it to work finally.
Thanks a lot for the amazing work.

I keep receiving sensor washer taking longer than expected/scheduled 0:00:10 error.
Can I increase polling/scanning interval manually?

Added a few specific options for Indian washers as well.

Quick question: Any reason for first mentioning STATE_xxxx = "UI Text" in wideq.py
Then adding those states in sensor/smatthinq_washer.py as an array

SPINSPEEDSTATES = {
  "UI Text" : wideq.STATE_xxxx,
}

Why not straightaway mention in sensor/smatthinq_washer.py directly?

that way can control machine with UI Text
you are right, it doesn’t necessary for washing machine because it is just sensing the machine’s state.

Quick question: Any reason for first mentioning STATE_xxxx = "UI Text" in wideq.py
Then adding those states in sensor/smatthinq_washer.py as an array
Why not straightaway mention in sensor/smatthinq_washer.py directly?

What could be the problem, if after giving example.py the link i recieved after loging in, I recieve an error:

KeyError: ‘item’

Under the account I logged in there is added the washer, at least I can see it from the Smartthinq app.