@wkd8176 the whole new ha structure (0.89) brought my climate with your code adapted by me down. I can monitor using example mon and example ac-mon, but there is a post error when the platform tries to be set up in ha at boot
Traceback (most recent call last):
File "/srv/hass_storage/apps/virtualenvs/homeassistant/lib/python3.6/site-packages/homeassistant/setup.py", line 154, 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 "/srv/hass_storage/home/.homeassistant/custom_components/smartthinq/__init__.py", line 39, in setup
client = wideq.Client.from_token(refresh_token)
File "/srv/hass_storage/apps/virtualenvs/homeassistant/lib/python3.6/site-packages/wideq.py", line 945, in from_token
client.refresh()
File "/srv/hass_storage/apps/virtualenvs/homeassistant/lib/python3.6/site-packages/wideq.py", line 932, in refresh
self._session, self._devices = self.auth.start_session()
File "/srv/hass_storage/apps/virtualenvs/homeassistant/lib/python3.6/site-packages/wideq.py", line 587, in start_session
session_info = login(self.gateway.api_root, self.access_token)
File "/srv/hass_storage/apps/virtualenvs/homeassistant/lib/python3.6/site-packages/wideq.py", line 509, in login
return lgedm_post(url, data)
File "/srv/hass_storage/apps/virtualenvs/homeassistant/lib/python3.6/site-packages/wideq.py", line 453, in lgedm_post
raise APIError(code, message)
wideq.APIError: (9003, '세션생성실패')
I have to modify wideq.py to fit my AC, gets installed into the ha venv via pip install -e . , so it creates the link, but at restart, init.py (i think) from smartthinq component overwrites the file
I’ve spent more time than I care to admin modifying this code to work for me with a US based Washer and Dryer. I’ve only tested the code for a washer and dryer and have been using hass.io for all my tests. Some of the code is pretty messy, as I wasn’t really planning on distributing past modifications for my project, but wanted to share with others that may find use in this.
It has been tested on:
Washer - WT7200CV
Dryer - DLE7200VE
From the below repo, if you are simply using a washer and dryer like me and no other applianced, the only file you really need is smartthinq/sensor.py and smartthinq/__init.py__ but I have left everything else as-is from the repo from @wkd8176 that it was forked from.
Then you’ll also need this fork of wideq, also based on @wkd8176, but you shouldn’t have to download this directly, as hass.io handles the install of wideq.
In hass.io, install the custom deps deployment, and use a config like this:
Remember, I only did modifications for a US based Washer and Dryer. If you are using other appliances, then I didn’t really change anything from the initial code. Good luck! Hope others may find this useful.
and click start it places it into the python3.6 directory rather than the python3.7 directory. This causes an error so i cloned the 3.6 directory, labeled it 3.7, restarted home assistant and now i can see my dryer information. My washer doesnt seem to be appearing though.
After restarting a few more times though my wideq in the python 3.7 directory has changed back to korean. Im not sure why the korean version keeps getting downloaded though. is it something to do with this part in the init.py file?
Okay that seemed to stop it from downloading the Korean version. I take it the user just has to place it into the 3.7 directory themselves or do I have something setup incorrectly that causes it to go into the 3.6 directory?
Also my washer still doesn’t seem to show up. My dryer works great but I don’t get any errors or anything about the washer that would point me where to go.
I take that back I got this error for my washing machine
Error doing job: Task exception was never retrieved
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 238, in async_update_ha_state
attr = self.state_attributes or {}
File "/config/custom_components/smartthinq/sensor.py", line 440, in state_attributes
data[ATTR_CURRENT_COURSE] = self.current_course
File "/config/custom_components/smartthinq/sensor.py", line 522, in current_course
course = self._state.current_course
File "/config/deps/lib/python3.7/site-packages/wideq.py", line 2401, in current_course
course = self.lookup_reference('Course')
File "/config/deps/lib/python3.7/site-packages/wideq.py", line 2351, in lookup_reference
return self.washer.model.reference_name(key, self.data[key])
KeyError: 'Course'
You are going to have lots of problems getting my code to work. You’ll probably need your own fork of the wideq code in GitHub and do your own modifications.
Some things you’ll need to do:
Figure out the “Course” thing. In the original code there is reference to “APCourse” which my washer knows nothing about, and it would keep complaining about this. I wound up commenting out this part of the sensor.py code, lines 506-516. You will need to start by looking at the wideq_state.json file that is in the same directory as wideq. You’ll see under “model_info” a url, navigate to that url in a browser. It should download a nicely formatted JSON file, and you can search in there for “Course” and see if it finds Courses. Then under the courses you’ll see the code names, like @WM_DRY27_COURSE_PERM_PRESS_W which you’ll need to make sure these are properly defined in wideq.py near line 2220.
You’ll have to ensure that all your options for states are listed properly in Wideq. So even the options you list for Soil, SpingSpeed and WaterTemp likely don’t match the available values in wideq today. Use that same JSON file referenced above.
A couple of your properties have different name than mine. For example, my washer uses WTemp but yours uses WaterTemp. You’ll have to modify line 2433 of wideq.py to say WaterTemp. This in particular was one that I had to hunt for an change since mine uses different property value than what it was expecting.
I commented out a lot of things, like TCLCount, since my washer has no concept of that. You may want to re-enable those in sensor.py around line 430.
Even when you get everything perfect, or so you think, then the washer may spit out a code during the cycle that breaks this. It’s all super frustrating to reverse engineer. Use that JSON file mentioned before, it really will have the keys to the kingdom.
That’s odd. Not sure how or what the code does to get that info. Either way, you can just look at that file where you found that info a little more. I believe everything that the link would have is the stuff that’s already in the file. The link simply has it formatted better but it all should be in that file that you need. Just dive into that and see what you find in terms of statuses and such.
Hi, what all do i need to change to get it working n other countries? Im in India, and have an LG AC. I have got it working with sampsyo’s repository. I would like to get the fan speed control, sweep control and fast cooling mode (known as ‘himalayas cool’ in indian ACs) working as well. Thanks in advance.
any ideas why i would be getting this error - running the latest sampsyo component from github.
I’ve checked the token created in example.py and it found the device and matches exactly.
Error while setting up platform smartthinq
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
return fut.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/smartthinq/climate.py", line 41, in setup_platform
client = wideq.Client.from_token(refresh_token)
File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 570, in from_token
client.refresh()
File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 556, in refresh
self._auth = self.auth.refresh()
File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 279, in refresh
self.refresh_token)
File "/srv/homeassistant/lib/python3.5/site-packages/wideq.py", line 232, in refresh_auth
raise TokenError()
wideq.TokenError
That error indicates that the LG servers rejected your authentication token. This might be related to the country where your account resides, or it could be worth trying to just generate a new token by authenticating again.
@samps
thanks for responding - I had this working for me before doing a rebuild - when i run the example.py it detects the device so it appears to be working OK at that level. I’ve tried a few refreshes now however still no luck.
also I have modified the wideq.py to match the Australian region
Had exactly the same problem (wideq.py modified to German account). At every restart my modified wideq.py is overwritten by the standard US one causing above error. Fixed it by commenting out the requirement line in manifest.json in custom_components/smartthinq.