In development: LG SmartThinQ component

@wkd8176

After reboot I had that error, what can I do?

Tue Jan 15 2019 14:24:42 GMT+0000 (GMT Standard Time)

Error while setting up platform smartthinq_hvac

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/climate/smartthinq_hvac.py", line 193, in setup_platform
    name = config[CONF_NAME]
KeyError: 'name'

Because korean smartthinq application has been updated can’t change device name for english.
HA can’t understand korean, so i updated my component that have to use name config.
If you add name config under the platform config, it will work.
You can see readme. I updated it

1 Like

@wkd8176 Tks ! Resolved that issue but now I had others :expressionless:

Error doing job: Task exception was never retrieved

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 352, in _async_add_entity
    await entity.async_update_ha_state()
  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/climate/smartthinq_hvac.py", line 336, in state_attributes
    data[ATTR_FAN_MODE] = self.current_fan_mode
  File "/config/custom_components/climate/smartthinq_hvac.py", line 399, in current_fan_mode
    mode = self._state.windstrength_state
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 1452, in windstrength_state
    return ACWindstrength(self.lookup_enum('WindStrength'))
  File "/usr/local/lib/python3.6/enum.py", line 291, in __call__
    return cls.__new__(cls, value)
  File "/usr/local/lib/python3.6/enum.py", line 533, in __new__
    return cls._missing_(value)
  File "/usr/local/lib/python3.6/enum.py", line 546, in _missing_
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: '@AC_MAIN_WIND_STRENGTH_HIGH_W' is not a valid ACWindstrength

My changes:

Configuration.yaml

Name air_conditioner because switch and sensors .

smartthinq:
    token: xxxxxx
climate:
    - platform: smartthinq_hvac
      name: air_conditioner    

smartthinq_hvac.py
Comment lines 334 to 349

   #supported_features = self.supported_features
    #if supported_features & SUPPORT_FAN_MODE:
    #    data[ATTR_FAN_MODE] = self.current_fan_mode
    #    if self.fan_list:
    #        data[ATTR_FAN_LIST] = self.fan_list

    #if supported_features & SUPPORT_OPERATION_MODE:
    #    data[ATTR_OPERATION_MODE] = self.current_operation
    #    if self.operation_list:
    #        data[ATTR_OPERATION_LIST] = self.operation_list

    #if supported_features & SUPPORT_SWING_MODE:
    #    data[ATTR_SWING_MODE] = self.current_swing_mode
    #    if self.swing_list:
    #        data[ATTR_SWING_LIST] = self.swing_list
    #return data

And 396 to 400

#@property
#def current_fan_mode(self):
#    if self._state:
#        mode = self._state.windstrength_state
#        return FANMODES[mode.name]

Wideq.py

Line 1450 to 1452

#@property
#def windstrength_state(self):
    #return ACWindstrength(self.lookup_enum('WindStrength'))

No had errors in DEV-INFO but no have any options . See image

Your ac has different swing option with mine.
You have to change wideq.py and smartthinq_hvac.py for your model.
mine is made for only korean medel(because i don’t have global model)

What country are you from?

@subzero79 Portugal

I am in Australia. What model number they sell there ? I can send you my adapter wideq, I disabled swing because my model has vertical and horizontal so it would be to much work to implement that. The climate component doesn’t have an option for secondary swing. I’ve added power consumption as an attribute to the ac also.

@subzero79

I have 3 Units:

2 x PM09SP
1 x PM12SP

When I run example.py appear that information:
xxxx: AC_1 (AC RAC_056905_PT)
xxxx: AC_2 (AC RAC_056905_PT)
xxxx: AC_3 (AC RAC_056905_PT)

If possible share your files , with @samps file all options appear,
Power consumption its a nice idea!

Here

https://gist.github.com/subzero79/5a0137c4e2746abb7196ada9db73e2fb

I still don’t have it in production yet coz my AC died, i am claiming warranty and needs a new board apparently

1 Like

@subzero79

Without any sucess.

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 843, in from_token
    client._auth = Auth(client.gateway, None, refresh_token)
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 742, in gateway
    self._gateway = Gateway.discover()
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 513, in discover
    gw = gateway_info()
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 417, in gateway_info
    {'countryCode': COUNTRY, 'langCode': LANGUAGE},
  File "/config/deps/lib/python3.6/site-packages/wideq.py", line 387, in lgedm_post
    with open('/home/ricardo/Documents/develop/homeassistant/wideq.txt','a', encoding="utf-8") as dumpfile:
FileNotFoundError: [Errno 2] No such file or directory: '/home/ricardo/Documents/develop/homeassistant/wideq.txt'

Update: After edit your file Wideq.py , all options appear ! I will test better and will give a feedback.

From

  res = requests.post(url, json={DATA_ROOT: data}, headers=headers)
    with open('/home/ricardo/Documents/develop/homeassistant/wideq.txt','a', encoding="utf-8") as dumpfile:
        json.dump(data, dumpfile, ensure_ascii=False, indent="\t")

out = res.json()[DATA_ROOT]

with open('/home/ricardo/Documents/develop/homeassistant/wideq_out.txt','a', encoding="utf-8") as dumpfile:
    json.dump(out, dumpfile, ensure_ascii=False, indent="\t")

To

res = requests.post(url, json={DATA_ROOT: data}, headers=headers)
    out = res.json()[DATA_ROOT]

by the way the attribute instant power_state are the power consumption? Only reported zero consumption “instant_power_state: 0”

This is gonna be difficult to implement officially in ha, the ac unit looks similar but options change a lot apparently. Did you edit the country code ?

I forgot that line it was for catching the outgoing post.

The instant power option might also be different. I added this by setting mitm proxy and adding a profile in my phone so I could see all the requests made from the app in plain.

so which fork is the best to use for the LG air conditioner? There are so many that I’m confused about which to use, i’m still on the original one, is there any feature or stability advantage of moving?

I haven’t been able to follow every detail, but I am still using my (original) code and it’s working great for me. If anyone has fixes or updates to the original AC functionality, I would love to merge them back into the main repo.

1 Like

thanks for the component, for the most part it works great however I saw some screenshots above that have more functionality.

I still think HA has a way to go handling AC units as opposed to the thermostat like controls it has, i’d be keen to see how you all are managing this on the frontend, i’m using the climate card however it doesn’t work very well, it seems that the HA devs dont understand there is an on/off state to air conditioning units

Hi @sharkpunch,
Did you have any luck getting the LG SmartThinQ component to work?
I’m from Aus too - I did the COUNTRY and LANGUAGE update as specified by @Aephir, but when I go to the URL and then log in, the next page I get says “Page not found error”

image

Check the link, you are redirected to. The link should contain both tokens needded.

For me - the script found the washer, but still Hassio shows unknown on all sensors :frowning:

 2019-01-17 17:40:17 WARNING (MainThread) [homeassistant.components.sensor] Platform smartthinq_washer not ready yet. Retrying in 90 seconds.
2019-01-17 17:38:47 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Pre state, the state is unknown. 
2019-01-17 17:38:47 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render template Steam mode, the state is unknown.

Are there any plans on this becoming an official component? Seems like the API is available upon registration. I wrote a request for this component few days ago and now just stumbled upon this page. Is this currently a working component, even with fridges? I’m planning on buying more LG related SmartThinkQ products to the home. Would love to see it work seamlessly with Hass.io.

1 Like

Which repo would you guys recommend to use for a US washer and dryer?

1 Like

Can this work when using HomeAssistant in a Docker ?