In development: LG SmartThinQ component

I updated my wideq.git
it had some wrong typo in the getting ac status code, plz try again

Before hand thanks for your work in this component. This time the traceback is different

2018-12-03 10:49:07 INFO (MainThread) [homeassistant.components.notify] Setting up notify.ios
2018-12-03 10:49:08 INFO (MainThread) [homeassistant.setup] Setup of domain media_player took 3.1 seconds.
2018-12-03 10:49:11 INFO (MainThread) [homeassistant.setup] Setup of domain smartthinq took 5.5 seconds.
2018-12-03 10:49:11 INFO (MainThread) [homeassistant.components.climate] Setting up climate.smartthinq_hvac
2018-12-03 10:49:21 WARNING (MainThread) [homeassistant.components.climate] Setup of platform smartthinq_hvac is taking over 10 seconds.
2018-12-03 10:49:25 INFO (SyncWorker_0) [custom_components.climate.smartthinq_hvac] Updating House AC.
2018-12-03 10:49:25 INFO (SyncWorker_0) [custom_components.climate.smartthinq_hvac] Polling...
2018-12-03 10:49:28 INFO (SyncWorker_0) [custom_components.climate.smartthinq_hvac] Status updated.
2018-12-03 10:49:37 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/opt/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 356, in _async_add_entity
    await entity.async_update_ha_state()
  File "/opt/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 232, in async_update_ha_state
    state = self.state
  File "/opt/homeassistant/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 207, in state
    if self.current_operation:
  File "/home/homeassistant/.homeassistant/custom_components/climate/smartthinq_hvac.py", line 375, in current_operation
    return MODES[mode.name]
KeyError: 'ACO'
2018-12-03 10:49:37 INFO (MainThread) [homeassistant.setup] Setup of domain climate took 32.7 seconds.

As i said, my component is made for korean model.
Korean model has no ACO mode so i delete it. You have to change your smartthinq-hvac.py, adding ACO mode.
Samps’s code will help you

1 Like

there is more to do, what is iceValley? i assume this has to be the equivalent for jet mode

It is also korean model only mode i think, if your model doen’t have icevalley mode, you can delete or change.
Ice valley mode is cooling fast mode, 18C, Full Power Wind strength.

Ok, so is called jet mode in my case according to the manual. I can see that running example getDevInfo info json file

Screenshot_2018-12-03_14-37-07
Screenshot_2018-12-03_14-37-24

edit: went an commented out all features that gave error. I am dealing now with the wind strength mode

For Hassio users, get the Custom deps deployment addon from the offical repo and use this code:

{
“pypi”: [
https://github.com/wkd8176/wideq/archive/master.zip#wideq
],
“apk”:
}

This will allow you to run wideq and hass-smartthinq custom components. I am using wkd8176 code for my washer and it kind of works but some changes are needed wideq.py to match my FH6F9BDSK2. States dosen’t match and it looks like some things are totally different. I am happy to have the state and time remaining up and running for now.

The wideq.py file will end up in:

config/deps/lib/python3.6/site-packages/wideq.py

@wkd8176: Strange thing using your custom component, I was not allowed to use refresh_token as the instructions say but i had to use token.

smartthinq:
token: ‘b605f:ALOTMORETEXT:2c1755’

I would like to do a data dump of the object that wideq gets from the LG API. Could anyone assist me with a code snippet for this that I can add to the wideq.py?

I will upload my setup when I have all functions up and running for the FH6F9BDSK2.

Oh. i’m sorry. Instruction is wrong.
Your right, it has to be ‘token’ not ‘refresh_token’.
I change the readme, thankyou.

Do you want to dump your washer’s states or washer’s api?
If you want api, you can use example.py with command below
& python3 example.py model DEVICEID

If you want states, use the code in annotation line 1979~1982.

 with open('/config/wideq/washer_polled_data.json','w', encoding="utf-8") as dumpfile:
        json.dump(res, dumpfile, ensure_ascii=False, indent="\t")

You have to change the json’s path if your environment is not synology with docker.

1 Like

@wkd8176 I am trying to create a smarthinq service for turning on the jet mode (icevalley equivalent I guess) trying to mimic the code from icevalley. Thing is jet mode has 3 on modes as you can see in the screenshot in one of my posts above.

I try to simplify just using cool_jet as on and off as off but didn’t work so a Boolean service. Looking at mitmproxy log when using the thinq iOS app I can see that Jet is the correct command but doesn’t work, when firing the service from ha.
Any insides on how to make wideq more verbose to see the payloads sent

I think it will work just swap ‘IceValley’ and ‘Jet’
just leave cool_jet, heat_jet, try Jet with template switch

I don’t why it didn’t work with duplicating the code, but changing to ‘Jet’ worked.

Now the AC, when is in heat mode, if you set Jet it will send a @COOL_JET payload, this works fine as the AC sets to @HEAT_JET accordingly, but the status reported back looks like is off. I added this to state_icevalley

@property
def icevalley_state(self):
    iv_state = self.lookup_enum('Jet')
    if iv_state in ('@COOL_JET','@HEAT_JET'):
        iv_state = '@COOL_JET'        
    return ICEVALLEY(iv_state)

there’s probably a better way to do this.

So it basically reports if jet is on or off, it would be @HEAT_JET if in heat and @COOL_JET if is in cool mode, otherwise we would have to set is an input_select menu.
The dry_jet and himalayas_jet I don’t have those opts, when i set it in my phone as dry and jet mode, it goes to cool mode.

The swing operation of the fins is much more complex, example.py mon reports this two value changes when i set the vertical or horizontal swing.

- WDirVStep: @OFF
- WDirHStep: @OFF

they change to this
image

Hello everyone!

I’ve managed to get basic functionality working on my washing machine, however since i’m really bad at python i can’t make any serious modifications to the code and mess with the states too much.

I’m using the component made by wkd8176 (Changed to the US endpoint)

My model is: F4J8TS2W (Listed as WTWS3 in the API)

Here’s a link to a dump of every available state: https://hastebin.com/anovubolad.json

I hope this is helpful in case anyone has the same or a similar model to mine (they seem to be quite popular in Greece and across the EU)

Would also appreciate it if someone more experienced than me could port over the proper states to the component :slight_smile:

Edit: Nevermind, i’ve managed to get most of the stuff working, now all thats left to do is to figure out how to get the Error codes to parse properly. Will update this post again with source code for anyone interested!

Please post source code that you got, I got lost going through this thread. Was hoping that all things would eventually be pushed back to @samps repository, but my washing machine doesn’t show up.

I’ve been messing with this for days, trying to get a washer and dryer working and nothing seems to work. I’ve seen so many different forks, and I have been trying to use the @phellarv fork of both wideq and hass-smarthinq, as it seems like this fork may be one of the more recent ones.

The latest that I’ve gotten to this is this. I have had to make a couple of changes to wideq.py to get past some of these errors, as for instance, the status reported of my washer was “@WM_STATE_COMPLETE_W” and that didn’t match a known state listed in wideq. I make a change like that to the wideq.py and add this state, and then there are still more errors like below.

Any ideas of how to get past all these? For the sake of the washer, trying to use this with LG WT7200CV. I never actually am able to get the washer added to HA in the first place, since it gets stuck on these setups so it appears.

2018-12-10 13:48:40 INFO (SyncWorker_2) [custom_components.sensor.smartthinq_washer] Updating WASHER.
2018-12-10 13:48:40 INFO (SyncWorker_2) [custom_components.sensor.smartthinq_washer] Polling…
2018-12-10 13:48:40 INFO (SyncWorker_2) [custom_components.sensor.smartthinq_washer] Status updated.
2018-12-10 13:48:42 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 239, in async_update_ha_state
attr = self.state_attributes or {}
File “/config/custom_components/sensor/smartthinq_washer.py”, line 212, in state_attributes
data[ATTR_CURRENT_COURSE] = self.current_course
File “/config/custom_components/sensor/smartthinq_washer.py”, line 284, in current_course
course = self._state.current_course
File “/config/deps/lib/python3.6/site-packages/wideq.py”, line 1990, in current_course
course = self.lookup_reference(‘APCourse’)
File “/config/deps/lib/python3.6/site-packages/wideq.py”, line 1940, in lookup_reference
return self.washer.

I’ve made a GitHub repository with my version of the component with everything else removed except the Washer component

For anyone using the EU models feel free to try this.

1 Like

@knackrack615, can you point out where you have made changes for “European” washers? Or, in other words, if I want to adapt this for use with US washers, where would I look to make the appropriate changes in your code?

@pjv All i did really was replace the Korean states with the ones found on the API dump for my washer (Example: Line 914-976 in wideq.py)

However, after looking at the dump from what my Washer publishes to the API i think my states might not only apply in the EU (There’s a “country”:“WW” in the API which i assume stands for Worldwide) but i can’t know for sure unless someone tests it on a different washer.

Using @knackrack615 branch, I still error out. No idea what “APCourse” is which is what it complains about.

2018-12-10 17:15:55 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/config/custom_components/sensor/smartthinq_washer.py", line 212, in state_attributes
    data[ATTR_CURRENT_COURSE] = self.current_course
  File "/config/custom_components/sensor/smartthinq_washer.py", line 284, in current_course
    course = self._state.current_course
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 1990, in current_course
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 1940, in lookup_reference
KeyError: 'APCourse'

Are you sure you’re using my branch? APCourse is completely removed from my version since its a Korean only thing (Not sure about that)

I’m not sure what’s the issue with my machine, I put all the code and have this in log:

2018-12-11 15:50:58 DEBUG (SyncWorker_3) [custom_components.sensor.smartthinq_washer] Creating new LGE Washer
2018-12-11 15:51:00 INFO (SyncWorker_3) [custom_components.sensor.smartthinq_washer] Connection Lost. Retrying.
2018-12-11 15:51:00 WARNING (MainThread) [homeassistant.components.sensor] Platform smartthinq_washer not ready yet. Retrying in 30 seconds.