In development: LG SmartThinQ component


#205

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


#206

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!


#207

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?


#208

You need to input some line in your wideq
Please see my wideq github 1035~1037 and paste yours


#209

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.


#210

No, you don’t need to do something.
Can you try to delete wideq in deps folder and restart HA two times?


#211

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?


#212

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.


#213

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.


#214

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.


#215

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…


#217

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.


#218

@fn87 - why what behaviour do you get?
Im just using a group and I get “Unknown” for each state which im happy with…


#219

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.


#220

just restart home assistant and my wideq.py file was reset back to korean again.


#221

how did you install the plugin?


#222

Yes I do get that as well but the plattform doesn’t initialize as it should and will retry for a couple of days or something like that.

I have to turn on my washer before that timeout limt for the integration to work.


#223

Do you have autostart on the Custom dependecy plugin?

Managed to do that a couple of times with an overwrite as the result.


#224

I think that eventually it will initialise, just that the time it waits grows exponentially.
Im sure ive seen code that say wait failureCount * waitTime for example.


#225

Okay i turned off autostart and now i got an error telling me that @WM_DRY27_DRY_LEVEL_NORMAL_W wasnt an available option.

So i went with what you said to do an added it into here

class DRYLEVEL(enum.Enum):
    
    IRON = "@WM_DRY24_DRY_LEVEL_IRON_W"
    CUPBOARD = "@WM_DRY24_DRY_LEVEL_CUPBOARD_W"
    NORMAL = "@WM_DRY27_DRY_LEVEL_NORMAL_W"
    EXTRA = "@WM_DRY24_DRY_LEVEL_EXTRA_W"

First thing i notice is that the error was saying DRY27 but in the DRYLEVEL section all of the others show up as DRY24. Do i ned to change anything else here?

After adding that part into DRYLEVEL i get this error now

ValueError: '@WM_DRY27_DRY_LEVEL_NORMAL_W' is not a valid DRYLEVEL

I also added this NORMAL mode into my sensor.py file but im not sure if i was supposed to or not.

DRYLEVELMODES = {
    'IRON' : wideq.STATE_DRY_LEVEL_IRON,
    'CUPBOARD' : wideq.STATE_DRY_LEVEL_CUPBOARD,
    'EXTRA' : wideq.STATE_DRY_LEVEL_EXTRA,
	'NORMAL' : wideq.STATE_DRY_LEVEL_NORMAL,
    'OFF': wideq.STATE_DRYER_POWER_OFF,    
}