look in your \deps\lib\python3.6\site-packages
folder and see if it created a wideq.py file there. If so then im pretty sure it did its job.
Hey guys, lots of usefull tips in here already!
I have a LG AC with smartthinq and I run hassio and I managed to get the token by modifying wideq.py to my country. Next step was to include wideq.py in my hassio install which also worked out with the Custom deps deployment addon. I verified this by checking \deps\lib\python3.6\site-packages
I created a folder .homeassistant/custom_component, gave it 777 rights and cloned into climate by:
git clone https://github.com/sampsyo/hass-smartthinq.git climate
I gave everything in the folder climate 777 rights as well.
In my config I have:
smartthinq:
token: xxxx
climate:
- platform: smartthinq
I keep seeing the following error in the log:
2019-02-24 17:51:32 ERROR (MainThread) [homeassistant.components.hassio] INFO:homeassistant.util.package:Attempting install of colorlog==4.0.2
Testing configuration at /config
Failed config
General Errors:
- Component not found: smartthinq
- Platform not found: climate.smartthinqSuccessful config (partial)
My folder structure looks like:
├── custom_components
│ └── climate
│ ├── LICENSE
│ ├── README.md
│ └── smartthinq.py
So seems like home assistant can’t find my smartthinq component. I don’t understand why? Do any of you have an idea?
Maybe we could update the readme with a hassio section as there seems to be some confusion among users. I’d be willing to do that!
Hi, I have a washer and dryer also but I haven’t started to integrate the device into my HA yet. Your API information (and others) would be very useful for me. Could you share your setup with me please?Thank you in advance!
did you ever get this figured out? Im stuck in the same spot
I did get further yes! I’m also active here where I’m trying to figure it out now: https://www.reddit.com/r/homeassistant/comments/auwptn/smartthinq_wideq_dependency/
Summary:
First of all, in hassio the custom_components needs to be in the same folder as config. Not in .homeassistant but in homeassistant without the dot!
Next thing in the wideq package which cannot be installed on hassio because it is not available on pypi.
Workaround: edit smartthinq.py:
REQUIREMENTS = [“https://github.com/sampsyo/wideq/archive/master.zip#wide1==0.0.1”]
Then I ran into a problem that I have to change my country-code in wideq and when using this workaround the wideq file is downloaded every restart. Therefore I made a fork of this repo with my own countrycode and used this link.
Now wideq is being loaded but I get the following errors which I’m still trying to figure out:
Error while setting up platform smartthinqTraceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 159, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw)
File “/usr/local/lib/python3.7/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.7/socket.py”, line 748, 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.7/site-packages/urllib3/connectionpool.py”, line 600, in urlopen chunked=chunked)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 343, in _make_request self._validate_conn(conn)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 839, in _validate_conn conn.connect() File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 301, in connect conn = self._new_conn() File “/usr/local/lib/python3.7/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 0x7fdd28829588>:
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.7/site-packages/requests/adapters.py”, line 449, in send timeout=timeout
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 638, in urlopen _stacktrace=sys.exc_info()[2]) File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError:
HTTPSConnectionPool(host=‘kic.lgthinq.com’, port=46030): Max retries exceeded with url: /api/common/gatewayUriList (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd28829588>:
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.7/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.7/asyncio/tasks.py”, line 416, 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/climate/smartthinq.py”, line 34, in setup_platform client = wideq.Client.from_token(refresh_token)
File “/config/deps/lib/python3.7/site-packages/wideq.py”, line 569, in from_token client._auth = Auth(client.gateway, None, refresh_token)
File “/config/deps/lib/python3.7/site-packages/wideq.py”, line 468, in gateway self._gateway = Gateway.discover()
File “/config/deps/lib/python3.7/site-packages/wideq.py”, line 244, in discover gw = gateway_info()
File “/config/deps/lib/python3.7/site-packages/wideq.py”, line 148, in gateway_info {‘countryCode’: COUNTRY, ‘langCode’: LANGUAGE},
File “/config/deps/lib/python3.7/site-packages/wideq.py”, line 124, in lgedm_post res = requests.post(url, json={DATA_ROOT: data}, headers=headers)
File “/usr/local/lib/python3.7/site-packages/requests/api.py”, line 116, in post return request(‘post’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/api.py”, line 60, in request return session.request(method=method, url=url, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘kic.lgthinq.com’, port=46030):
Max retries exceeded with url: /api/common/gatewayUriList (Caused by NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x7fdd28829588>:
Failed to establish a new connection: [Errno -3] Try again’))
Fighting custom components and directory structure sounds like some of the issues I had. Are you on HA .88?
Look at this post where I started getting traction and if it is in the same area, it might help.
Here is the link for what it is worth. https://community.home-assistant.io/t/custom-cover-is-not-working-now-but-was-in-previous-ha-versions/101255/8?u=penright
I read this and I switched the directory and filename around now. So I have folder smartthinq and climate.py instead of climate and smartthinq.py. I get errors again but these seem to be related to the token!
Error while setting up platform smartthinq
Traceback (most recent call last):
File "/usr/local/lib/python3.7/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.7/asyncio/tasks.py", line 416, 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/climate.py", line 34, in setup_platform
client = wideq.Client.from_token(refresh_token)
File "/config/deps/lib/python3.7/site-packages/wideq.py", line 570, in from_token
client.refresh()
File "/config/deps/lib/python3.7/site-packages/wideq.py", line 556, in refresh
self._auth = self.auth.refresh()
File "/config/deps/lib/python3.7/site-packages/wideq.py", line 279, in refresh
self.refresh_token)
File "/config/deps/lib/python3.7/site-packages/wideq.py", line 232, in refresh_auth
raise TokenError()
wideq.TokenError
So I guess we’re going in the right direction…
Edit, I got it working! The problem was in the language. For me it has to be set as:
COUNTRY = ‘NL’
LANGUAGE = ‘nl-NL’
I thought that setting only the country sufficed but apparently not. Weird since the app is in English with me.
I will post a step by step manual for hassio users here: https://github.com/sampsyo/hass-smartthinq/issues/9
Thanks all for helping!
I’ve had limited success with this over the past few months with an older version of this code. I’m in the process of trying to update this with @wkd8176’s recent code (in hopes that it will be stabler) with a US washer and dryer. I can get logged in with the python script to the API on LG’s side, and pull attributes from there.
I had to comment out a few lines here and there where the code was failing, but I then get to this important part of the code that I can’t get past.
2019-03-10 12:02:23 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform smartthinq
Traceback (most recent call last):
File "/usr/local/lib/python3.7/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.7/asyncio/tasks.py", line 416, 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/sensor.py", line 310, in setup_platform
model_type = model.model_type
AttributeError: 'ModelInfo' object has no attribute 'model_type'
If I comment out the line in sensor.py where it is complaining about that, it fails on the next setup steps, which are where it asks for the mac address.
For reference, here is the configuration I have:
smartthinq:
token: 36–redacted–e1
sensor:
- platform: smartthinq
name: dryer
mac: 20:3d:bd:xx:xx:xx
And ideas?
You need to input some line in your wideq
Please see my wideq github 1035~1037 and paste yours
I’m not fully following you here. What do I need to input and where? 1035 to 1037 looks like this (I am using your latest version of wideq from https://github.com/wkd8176/wideq):
@property
def model_type(self):
return self.data['Info']['modelType']
Do I need to manually do anything here, or should it pick everything up from the api already? I can run python3 example.py and it finds my washer and dryer without an issue.
No, you don’t need to do something.
Can you try to delete wideq in deps folder and restart HA two times?
Im having an issue with rendering the data from this.
Ive somehow got the data into HA (using hass.io by changing import wideq to from . import wideq
) after 4 days:
But id like it to render more like:
I have added a group with what I think the sensor name should be but the values id like to show seems to be attributes of the sensor entity, not actual entitites themselves.
Configuration:
smartthinq:
token: 1380797SAUSAGE5c67cc96baSPIDERMAN8c27fc1990e9cf56f983f50a
Sensors
- platform: smartthinq_washer
name: Washing Machibe
mac: 20:3d:XX:61:XX:7d
Can someone please help me with the rendering?
That view is a combination of Lovelace and template sensors.
Template sensor code where my sensor with all the data is called tvattmaskin.
https://pastebin.com/mdRqpxnq
Code for Lovelace view:
https://pastebin.com/FawNgFCJ
Then there is some code automation related to the progressbar and my fake light but it has some bugs so I think you would be better of without that.
Do you have an 3.7 folder in deps? I had to change to 3.7 a while back and moved the package to 3.7 as well.
Thanks for the reply about the template sensor code and custom view.
Can you help or provide docs on how to implement?
Ive tried using a group but as the individual values are exposed as states/attributes, I cant get access as groups seem to only want entities.
I dont have the deps folder. I got it working by putting wideq.py in the same folder and referencing locally.
EDIT: Worked it out - the template sensor code needs to go in configuration.yaml under sensors as per: https://www.home-assistant.io/components/sensor.template/
That exposes the attributes as individual sensors.
Glad that I could help!
I wish I had some time to find a solution to the timeout that occures if I do not turn on my washer after a HASS restart…
i switched it over to 3.7 and then had to comment out a few lines to get it to stop throwing errors. I kept doing that until it actually kind of started working. I restarted home assistant and started seeing all of teh sensors pop up without any real information being put into the sensors.
so i decided to try starting the dryer and then restarting home assistant and then i get this error
Error doing job: Task exception was never retrieved
ValueError: '@WM_STATE_DRYING_W' is not a valid DRYERSTATE
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
await entity.async_update_ha_state()
File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 232, in async_update_ha_state
state = self.state
File "/config/custom_components/smartthinq/sensor.py", line 674, in state
run = self._state.run_state
File "/config/deps/lib/python3.7/site-packages/wideq.py", line 1768, in run_state
return DRYERSTATE(self.lookup_enum('State'))
File "/usr/local/lib/python3.7/enum.py", line 309, in __call__
return cls.__new__(cls, value)
File "/usr/local/lib/python3.7/enum.py", line 561, in __new__
raise exc
File "/usr/local/lib/python3.7/enum.py", line 545, in __new__
result = cls._missing_(value)
File "/usr/local/lib/python3.7/enum.py", line 574, in _missing_
raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: '@WM_STATE_DRYING_W' is not a valid DRYERSTATE
i cant even find the enum.py file to look into what could be the problem.
@fn87 - why what behaviour do you get?
Im just using a group and I get “Unknown” for each state which im happy with…
Its in wideq.py.
Heres a output of dryer states:
class DRYERSTATE(enum.Enum):
OFF = "@WM_STATE_POWER_OFF_W"
INITIAL = "@WM_STATE_INITIAL_W"
RUNNING = "@WM_STATE_RUNNING_W"
PAUSE = "@WM_STATE_PAUSE_W"
END = "@WM_STATE_END_W"
ERROR = "@WM_STATE_ERROR_W"
Probably just needs adding in there.
just restart home assistant and my wideq.py file was reset back to korean again.