LG Smartthinq Air Conditioning

I am quite confident with linux. I am a network engineer that uses linux daily. I have also been on the development team for 2 commercial IoT devices.

My AC model is the LW1817IVSM
A bit of backstory, I originally tried just doing a vanilla wideq install so I could code up my own webpage and host it on a home server. Wideq never ended up working, but the wideq fork that implements the v2 api sort of did. It could find the AC unit, but not communicate with it. This lead me to the home assistant community. I installed the sampsyo stuff just as asked.

My directory structure is as follows:

/config

custom_components
smartthinq
wideq

After grabbing the refresh token the configuration.yaml file looks like this


Home assistant was rebooted and nothing came up. The next thing I tried to do to troubleshoot was switch out the wideq api v1 and apiv2 repositories and replace the refresh token in configuration.yaml. No dice. I have switched it back and here we are.

If you need more info just let me know. Thank you so much for your time!

Regards,
Jon

1 Like

Ok, so different levels of t/shooting then by the looks…

@brazil885 - you need to get a CLI up yes, certainly just for step1 (getting wideq to give you back a token, you need to type some stuff and get back other stuff - the token - to copy/paste into your config.yaml). I have a different setup to you (i dont use hassio) but some googling seems to show you can install some stuff to get access to your CLI. See --> Can't access hassio command line from hass.io installed on Ubuntu

@MrPotshot - no way, im actually a network engineer too! :slight_smile: first thing that jumps out at me is your directory structure is wrong (if i understand your snip correctly), smartthinq and wideq need to be under custom_components i believe. At least they are for me.
image

Then after that, and a clean boot, mine just sprung to life - specifically i could see climate.XXXX (XXXX is what you name the device in your LG smartthinq app - for me its ‘air’) so i get the following in developer -> states:

what does your boot up look like? mine looks like this (i schedule a nightly reboot of hass at 1am) - pretty clean in the logs from a smartthinq point of view just one warning (and some other failure at 5am for some other reason - shitty LG API i guess), and then if i look for climate.air in the same log, i get the occasional warning its taking > 10 secs to poll the API (again, same reason!).

Hopefully this gives you enough of a comparison point to crack your problem.

Good luck both!

thanks for the help, when I put the line python3 example.py -c IT -l it-IT, it tells me COMMAND NOT FOUND

Can i get a screenshot? Ive no idea how hassio works to give you a shell. But i suspect its either a PATH problem to python3 (please also type “which python3” to help here) or you are not executing the example.py script from the wideq directory (typing “pwd” will help me here too so please type that too). Screenshot of all this will help. Thanks!

Hi! You are Brazilian? I’m brazilian and I believe I had some problems like you. Maybe I can help you, and if you speak portuguese, can be easier.

Hi Brazil885! Yes, I’ll try help you in english (Google Translate can help me, lol), so I apologize for any mistakes with the language.

In reality “hassio” works with background linux. However, I spent days and nights researching and trying to understand what nobody explains, which is how to give the command in Python inside the Home Assistant.

First of all, copy the “smartthinq” and “wideq” folders that you downloaded from the repository to the “custom_components” folder, which in turn must be inside “config”!

Now that the secret comes, lol … After a lot of research and several attempts, I finally found out that I needed to use an “Add-on” in the Home Assistant, called “Portainer”, that’s where you’ll run example.py with Python.

To do this, go to “Surpevisor” >> “Add-on Store” and search for “Portainer”. After installing it, go to “Configuration” and add these two lines:

log_level: info
agent_secret: YOUR PASSWORD FOR HOME ASSISTANT

Save. Returns to “Info”. Enable “Show in sidebar” and disable “Protection mode”. You can now start “Portainer”.

Open the “Portainer” in the sidebar. Click on “Primary” on the home screen, then click on “Container”, this will show “homeassistant”. In the “Quick actions” column, click on Exec Console (> _), then on “Command”, select “/ bin / ash” and click “Connect”.

The console written: “/ config #” will open. Then type: “cd custom_components” (without quotes) and press Enter. The console will then display: “/ config / custom_components #”. Type now: “cd wideq” (again without quotes). At that moment you will be inside the “wideq” folder under “custom_components”. Now just type the command “python3 example.py -c US -l en-US” with your country and language. This will return a link, which you must copy and paste into your browser. This link will open a LG Smartthinq login screen. Log in with your username and password, (it will not work if you are logging in with Google) this will open a blank screen, but it does not matter, as you will only need what is written in the address bar. Copy the code between “refresh_token =” and “&”.

Now just open the file “” and type the following lines:

smartthinq:
  token: YOUR TOKEN CODE
  region: YOUR COUNTRY
  language: YOUR LANGUAGE
  • Attention to the tabulation of the lines above.

Save the file. Return to the Home Assistant, validate the configuration and restart the server.

After restarting the home assistant, your air conditioning should be set to “Unused entities”.

I hope everything goes well, but if you encounter any problems let me know so I can try to help you.

1 Like

Hi thanks for the mini guide, it gives me this error, where do you think I’m wrong?

1 Like

Try entering this line before you call your python3 command

export PYTHONPATH="${PYTHONPATH}:/config/custom_components/wideq/"

then I managed to do everything, but once restarted I don’t see the entities. I have 2 air conditioners but I don’t see them. Filipecalvo says I visualize them in Unused entities, but where are they located?

I reckon it might be to do with the fact that your hassio container setup forgets the EXPORT command that I mentioned above, between reboots. Sorry again, i dont run mine with hassio so its a bit of guesswork. The best way to start troubleshooting this is check your /config/home-assistant.log file. Do you get any errors in there regarding wideq or smartthinq when you boot up?

2020-07-04 00:20:02 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for alexa_media which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-07-04 00:20:02 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-07-04 00:20:02 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for smartthinq_sensors which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-07-04 00:20:02 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for smartthinq which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-07-04 00:20:03 WARNING (MainThread) [homeassistant.components.http] The ‘base_url’ option is deprecated, please remove it from your configuration
2020-07-04 00:20:07 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for samsungtv_tizen which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
2020-07-04 00:20:27 ERROR (SyncWorker_2) [homeassistant.components.google_maps.device_tracker] The cookie file provided does not provide a valid session. Please create another one and try again.
2020-07-04 00:20:27 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy
2020-07-04 00:20:28 WARNING (MainThread) [homeassistant.components.climate] ClimateDevice is deprecated, modify LGDevice to extend ClimateEntity
2020-07-04 00:20:32 ERROR (MainThread) [homeassistant.components.vacuum] xiaomi_miio: Error on device update!
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 319, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 466, in async_device_update
self.update # type: ignore
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/xiaomi_miio/vacuum.py”, line 470, in update
state = self._vacuum.status()
File “/usr/local/lib/python3.7/site-packages/miio/vacuum.py”, line 197, in status
return VacuumStatus(self.send(“get_status”)[0])
File “/usr/local/lib/python3.7/site-packages/miio/device.py”, line 147, in send
command, parameters, retry_count, extra_parameters=extra_parameters
File “/usr/local/lib/python3.7/site-packages/miio/miioprotocol.py”, line 150, in send
self.send_handshake()
File “/usr/local/lib/python3.7/site-packages/miio/miioprotocol.py”, line 62, in send_handshake
header = m.header.value
AttributeError: ‘NoneType’ object has no attribute ‘header’

some idea?

Those logs are ok. WARNINGS are ok. ERROR lines are not.

Could it be you just dont know how to tell if its been detected ok?

What did you call your LG in the smartthinq app? For me, its “air” so what i have is “climate.air”. Go to developer->states and search in your browser for “climate” - see what you find.

thanks for the help, but no entity appears to me, something is wrong!in my opinion this line of the log has something to do with it:
2020-07-06 21:18:51 WARNING (MainThread) [homeassistant.components.climate] ClimateDevice is deprecated, modify LGDevice to extend ClimateEntity

Could SmartThinQ LGE Sensors conflict with this component?

After struggling to get the integration working with my LG AC (no device listed in both wideq and HA) I tried to use a fork of wideq:

I repeated the setup process with this wideq fork and was able to list my device. Then I changed the HA config to reflect the newly generated refresh token and restarted HA. Unfortunately, the device was not listed in HA (checked via Configuration > Devices and Developer Tools > States).

In the logging I found the same warning as @brazil885:

2020-07-09 15:39:41 WARNING (MainThread) [homeassistant.components.climate] ClimateDevice is deprecated, modify LGDevice to extend ClimateEntity

In another topic I found that the custom integration should probably be updated:

Could this be the cause of my problem?

Another question: when correctly installed, should the SmartThinq integration pop up in the HACS or HA Integration sections? I don’t see it in both sections:


hello, I have not yet managed to integrate them, let’s see if we can.

Hmm interesting @Neoc83. I had no idea that fork existed, did you dive into why they did it? Sampsyo code obv works fine for me, but wondering if its LG device dependant.

I DONT get those warning in my logs. See my grep looking for any hits on ‘limate’ (capital or lower case c) just now

Sampsyo is very responsive, ive pinged him a few times on github via the ‘raise a new issue’. I wonder if he is aware of the update that hass is asking of him. Perhaps log a new issue if not?

What version of hass are you guys on? Im on v0.107.7 (and confirm it was working to versions a year earlier than that), and in versions upto v0.111 (i had to roll back as something else not related to this broke on the very latest code)… but i cant comfirm i didnt see that same warning. I still dont think thats your problem (its a warning only, and ive seen that a few times before for other things if i recall correct) but not 100% here.

As to if it shows up in integrations, dont think so (i never hunted for it there), sorry. Dev tools -> states defo the place to hunt IMO.

Well it could be device dependent but I expect more people to suffer from it then. From what I can tell the fork is API v2 specific. Apparently there is an API v1 and v2. Maybe that’s also causing the issues. I’m on HA v0.112.4 btw.

I tried some additional things like I was able to install in HASS and it now shows up in the HASS integration:


(For people like me that couldn’t find it: to add custom integrations you need to go to HASS > Integrations > 3 dots icon > Custom integrations)
However, that was causing the same Warning message and still no devices.

Then, I saw a suggested quick fix for the sampsyo repo that was not released yet:

I applied the fix (just a single line of code needs to be changed) and the warning is gone now but still no luck with the device in HA.

I’m thinking of diving into the world of Python programming to see if I can work out a solution myself :-).

I installed this software i get 2 tokens (washing machine and aircodnition). When I add this to configuration file i recive error “The following integrations and platforms could not be set up: smartthinq

Marcin

@Neoc83 have you tried running wideq from the command line? Heres and example of mine thats working. You plug in the first command, get its output and insert into the second (and third) command. If you DONT get values back like mine then that would be something to look into (sorry for night mode colors on my screenshot!)

Good soot on the issue on GitHub by the way (bless that platform!). And yeah it seems i was right, dont reckon thats your issue

1 Like