sampsyo / hass-smartthinq

Home Assistant component for LG SmartThinQ HVAC devices
MIT License
285 stars 98 forks source link

Hass.io setup guide please #9

Open ctih opened 5 years ago

ctih commented 5 years ago

Hope someone can help setting up on hass.io? 😊

jlo88 commented 5 years ago

Instructions that worked for me:

Make a folder custom_components in the folder where you home-assistant config.yaml is:

sudo -s mkdir custom_components cd custom_components

Clone the repository in a folder called smartthinq: git clone https://github.com/sampsyo/hass-smartthinq.git smartthinq

Rename the smartthinq.py file in that folder to climate.py: cd smartthinq mv smartthinq.py climate.py

Now for the wideq part, make a temporary folder and clone the repository:

cd ~ mkdir tmp git clone https://github.com/sampsyo/wideq.git tmp cd tmp/wideq pip3 install -e .

From here on follow the instructions 3 and 4. If you cannot log in for example it says your account does not exist, edit the wideq.py file by changing both the country and the language and trye again. When you obtained the token you could remove the temporary folder by:

rm -r ~tmp/wideq

Now one more step is required because home-assistant needs to be able to find and use wideq. I did this by editing my climate.py file.

Go to the home-assistant folder where config.yaml is:

cd your/hassio/folder/homeassistant/custom_components/smartthinq nano climate.py

Look for the line that says:

REQUIREMENTS = ['wideq']

Replace this line with

REQUIREMENTS = ["https://github.com/sampsyo/wideq/archive/master.zip#wide1==0.0.1"]

This only works if you're living in the US. If you don't, you can fork this repository and make the necessary changes. I did this here for example for me in the Netherlands:

https://github.com/jlo88/wideq

I changed lines 17 and 18:

COUNTRY = 'NL'
LANGUAGE = 'nl-NL'

You can then use your own repository by:

REQUIREMENTS = ["https://github.com/yourrepositoryname/wideq/archive/master.zip#wide1==0.0.1"]

This made it work for me!

I'm still looking for a solution where I don't have to host wideq on github but can just store the files somewhere on my own server but I didn't get this working. If anyone knows a way for this, please let me know!

arevinje commented 5 years ago

Noob question: Running Home Assistant 0.89.1, Hassio 148. For those of us running in this setup, i.e. not having access to pip3 or python3 etc in SSH, what is the installation procedure?

Copied wideq.py and the example.py script to my python_scripts folder and tried running it from HA Services page with no luck.

jlo88 commented 5 years ago

Noob question: Running Home Assistant 0.89.1, Hassio 148. For those of us running in this setup, i.e. not having access to pip3 or python3 etc in SSH, what is the installation procedure?

Copied wideq.py and the example.py script to my python_scripts folder and tried running it from HA Services page with no luck.

You don't have to run the wideq.py from your home-assistant device. You can run it from any device with python3 on it and copy paste the token to your home-assistant config.

bessss89 commented 5 years ago

Hi, I follow step by step you instructions and I am able to discovery the "refresh_token" but after configure the configuration.yaml with "platform" and "refresh_token", my HA don't discover any new climate entity. I'm runnin Hass.io 165 and HA 0.93.2 I've repeated the procedure many times but I never saw any new entity in HA. Can someone help me, please?

jlo88 commented 5 years ago

Hi, I follow step by step you instructions and I am able to discovery the "refresh_token" but after configure the configuration.yaml with "platform" and "refresh_token", my HA don't discover any new climate entity. I'm runnin Hass.io 165 and HA 0.93.2 I've repeated the procedure many times but I never saw any new entity in HA. Can someone help me, please?

Are you sure you adjusted the language in wideq and hosted it on your own github account?

bessss89 commented 5 years ago

Yes but seems like HA in Hass.io use the pre-installed wideq witch have en-EN language and even if i change that parametres to it-IT, they return default every times i restart HA. I also change the climate.py with the correct string in "REQUIREMENTS", using my wideq.py with the corrrect language parametres. Is it possible that the last version of Hass.io ignore the it-IT configuration inside wideq and use the default en-EN?

jlo88 commented 5 years ago

So you did this?

Go to the home-assistant folder where config.yaml is:

cd your/hassio/folder/homeassistant/custom_components/smartthinq nano climate.py

Look for the line that says:

REQUIREMENTS = ['wideq']

Replace this line with

REQUIREMENTS = ["https://github.com/sampsyo/wideq/archive/master.zip#wide1==0.0.1"]

This only works if you're living in the US. If you don't, you can fork this repository and make the necessary changes. I did this here for example for me in the Netherlands:

https://github.com/jlo88/wideq

I changed lines 17 and 18:

COUNTRY = 'NL' LANGUAGE = 'nl-NL' You can then use your own repository by:

REQUIREMENTS = ["https://github.com/yourrepositoryname/wideq/archive/master.zip#wide1==0.0.1"]

If that doesn't work I'm also not sure how to get your own wideq working..

bessss89 commented 5 years ago

I've tried to register it with a USA LG account and integrate in HA the A/C and apparently it work but using this approach i can't use the original LG app because if i try to set the usage mode or the fan speed, appears a message in the LG app that tell me something like "another user is using this product so you can do anithing till he disconnect his session" I use the original app only to regulate fan speen and air swing. Is there some changes to do in the climate.py to add theese two option to the HA entity?

sampsyo commented 5 years ago

That’s normal—the monitoring we do seems to acquire exclusive access to the device. Not sure why LG doesn’t let two apps communicate with the same device at the same time.

bessss89 commented 5 years ago

Ok understood! And what about the second question? Is there any way to integrate fan speen and air swing in the HA entity? Thanks

sampsyo commented 5 years ago

It's possible, but it will require some hacking! I have done the reverse-engineering to sort out the fan speed option in wideq, but not the rotation/swing parameter. So for the former, it's a matter of exposing this parameter in the HA component. For the latter, we'd need to add that and do some digging to figure out the interface for the swing parameter in the LG API.

Any help/PRs on these would be greatly appreciated!

bessss89 commented 5 years ago

Honestly the rotation/swing isn't much important. How can I expose the fan speed parameter from wideq to HA? I read the code of your's climate.py but onestly I'm not so good at programming and I have no idea where to start to expose this parameter

sampsyo commented 5 years ago

@bessss89, maybe we should discuss this in a new issue just about fan speed?

In any case, the device class will need to implement these methods from the HA API:current_fan_mode and fan_list. And declare that it has the SUPPORT_FAN_MODE feature.

Gerben321 commented 5 years ago

I followed @jlo88 's little guide and it looked promising. However, I get an error:

Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 126, 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 45, in setup_platform client = wideq.Client.from_token(refresh_token, country, language) File "/config/deps/lib/python3.7/site-packages/wideq.py", line 601, in from_token client.refresh() File "/config/deps/lib/python3.7/site-packages/wideq.py", line 584, in refresh self._auth = self.auth.refresh() File "/config/deps/lib/python3.7/site-packages/wideq.py", line 289, in refresh self.refresh_token) File "/config/deps/lib/python3.7/site-packages/wideq.py", line 238, in refresh_auth raise TokenError() wideq.TokenError

Any idea? Followed the URL that the CLI gave me, entered the URL my browser redirected me to, and then copied the token from the .json file and entered it in my yaml.

sampsyo commented 5 years ago

Unfortunately no! The API is telling you that your token is invalid, but it’s not telling you why.

xpokor02 commented 4 years ago

So you did this?

Go to the home-assistant folder where config.yaml is:

cd your/hassio/folder/homeassistant/custom_components/smartthinq nano climate.py

Look for the line that says:

REQUIREMENTS = ['wideq']

Replace this line with

REQUIREMENTS = ["https://github.com/sampsyo/wideq/archive/master.zip#wide1==0.0.1"]

This only works if you're living in the US. If you don't, you can fork this repository and make the necessary changes. I did this here for example for me in the Netherlands:

https://github.com/jlo88/wideq

I changed lines 17 and 18:

COUNTRY = 'NL' LANGUAGE = 'nl-NL' You can then use your own repository by:

REQUIREMENTS = ["https://github.com/yourrepositoryname/wideq/archive/master.zip#wide1==0.0.1"]

If that doesn't work I'm also not sure how to get your own wideq working..

Hi it didn't worked for me so I ssh into docker a installed by pip3 install wideq I no longer get error about missing wideq but "ValueError: '@AC_MAIN_WIND_STRENGTH_NATURE_W' is not a valid ACFanSpeed" Thanks

Tomek985 commented 4 years ago

Yes but seems like HA in Hass.io use the pre-installed wideq witch have en-EN language and even if i change that parametres to it-IT, they return default every times i restart HA. I also change the climate.py with the correct string in "REQUIREMENTS", using my wideq.py with the corrrect language parametres. Is it possible that the last version of Hass.io ignore the it-IT configuration inside wideq and use the default en-EN?

I may be experiencing same problem like you did, I am trying to use custom wideq version (to work with washers in OFF state), but it seems HA is loading other version that is missing that relevant CONST. I changed requirements REQUIREMENTS = ['https://github.com/bdf0506/wideq/archive/master.zip#wide1==0.0.1'] in init for smathinq

Cortex33 commented 4 years ago

Hello, how can I install python3 in hass.io system ? I'm stuck at this point, thanks for your help I try to apt install python3 but the command apt is not recognized by Hass.io ... So I don't know what to do if I can have some help thanks in advance.