hass-smartthinq icon indicating copy to clipboard operation
hass-smartthinq copied to clipboard

Integration with HA

Open bmwm69 opened this issue 7 years ago • 32 comments

Hello,

how integrate that with HA ?

bmwm69 avatar Feb 17 '18 13:02 bmwm69

Please see: https://home-assistant.io/developers/development_101/

This repository needs to be cloned into custom_components in your Home Assisrsnt directory. It also needs this Python dependency installed with pip: https://github.com/sampsyo/wideq

sampsyo avatar Feb 17 '18 15:02 sampsyo

Hi I installed wideq with pip, and cloned smartthinq.py in custom_components.

How to register my AC in HA?

wkd8176 avatar Mar 30 '18 16:03 wkd8176

Good question! I added some instructions to the README just now. Let me know if that's not clear.

sampsyo avatar Mar 30 '18 22:03 sampsyo

Nice new readme file ! :) For hass.io system some alternative to install wideq ?

bmwm69 avatar Mar 31 '18 04:03 bmwm69

Sorry, I’m not familiar with hass.io. Maybe there’s some way to specify WideQ as a dependency?

sampsyo avatar Mar 31 '18 04:03 sampsyo

Thank you the updated README. I logged in the lgaccount, site said 'Invalid request parameter'

What can i do more? please help

wkd8176 avatar Mar 31 '18 16:03 wkd8176

Huh! I don’t know what’s wrong, but I do know that some folks on the Ha forum have found that they need to adjust the initial login endpoint to match their country. Taking a look there might reveal some clues.

sampsyo avatar Mar 31 '18 17:03 sampsyo

Oh, it was problem of internet browsers. I retried this in iExplorer, it worked.

and I also changed wideq.py little bit.(Because I live in South Korea)

There is another problem. I got a refresh token, and paste it in the configuration.yaml and i got an error like this

2018-04-03 00:34:21 WARNING (MainThread) [homeassistant.components.climate] Setup of platform smartthinq is taking over 10 seconds. 2018-04-03 00:34:21 ERROR (MainThread) [homeassistant.components.climate] Error while setting up platform smartthinq Traceback (most recent call last): File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 84, in async_setup 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/asyncio/futures.py", line 243, in result raise self._exception 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.py", line 35, in setup_platform add_devices(LGDevice(client, device) for device in client.devices) File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 121, in _schedule_add_entities self._async_schedule_add_entities, list(new_entities), File "/config/custom_components/climate/smartthinq.py", line 35, in add_devices(LGDevice(client, device) for device in client.devices) File "/config/custom_components/climate/smartthinq.py", line 56, in init self.update() File "/config/custom_components/climate/smartthinq.py", line 180, in update state = self._ac.poll() File "/config/wideq.py", line 693, in poll res = self.mon.poll() File "/config/wideq.py", line 354, in poll

wkd8176 avatar Apr 02 '18 15:04 wkd8176

That traceback is cut off. Can you try pasting again, and this time use Markdown code fences so it's readable?

sampsyo avatar Apr 02 '18 16:04 sampsyo

Sorry. I paste it again I'm using HA on docker, synology nas.

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 84, in async_setup
    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/asyncio/futures.py", line 243, in result
    raise self._exception
  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.py", line 35, in setup_platform
    add_devices(LGDevice(client, device) for device in client.devices)
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 121, in _schedule_add_entities
    self._async_schedule_add_entities, list(new_entities),
  File "/config/custom_components/climate/smartthinq.py", line 35, in <genexpr>
    add_devices(LGDevice(client, device) for device in client.devices)
  File "/config/custom_components/climate/smartthinq.py", line 56, in __init__
    self.update()
  File "/config/custom_components/climate/smartthinq.py", line 180, in update
    state = self._ac.poll()
  File "/root/wideq/wideq.py", line 693, in poll
    res = self.mon.poll()
  File "/root/wideq/wideq.py", line 354, in poll
    return self.session.monitor_poll(self.device_id, self.work_id)
  File "/root/wideq/wideq.py", line 309, in monitor_poll
    base64.b64decode(res['returnData']).decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 6: invalid start byte

wkd8176 avatar Apr 02 '18 22:04 wkd8176

Interesting! I can see what’s going wrong (non-UTF-8 data for the JSON response) but I’m not sure what to fix it (i.e., what the right encoding is). Any chance you’d be willing to give me a credential (i.e., an access token) privately so I can investigate further? I promise not to change any settings... :smiley:

sampsyo avatar Apr 03 '18 00:04 sampsyo

I sent a mail inside of ‘wideq_state.json’ Please check your mail

wkd8176 avatar Apr 03 '18 12:04 wkd8176

Thanks!

The problem was that you have other, non-AC devices on your account. I only have AC devices from LG, so I just used all the associated devices and assumed they were AC devices. It turns out that other things (e.g., refrigerators) report their status in a very different way.

Anyway, I've now added some code to WideQ to detect the types of devices. This plugin now uses that to only try to use AC devices. If you update both the WideQ library and this plugin, you should be in business.

sampsyo avatar Apr 03 '18 14:04 sampsyo

Hello,

Steps by step to install in Hass.io

Install Phyton $apk add --no-cache python3 $ git clone https://github.com/sampsyo/wideq.git $ cd wideq $ pip3 install -e . $ cd /config $ mkdir custom_components $ cd custom_components $ git clone https://github.com/sampsyo/hass-smartthinq.git climate $cd /wideq

In my case I modify wideq.py COUNTRY = 'PT' LANGUAGE = 'pt-PT'

The file wideq_state.json apear with refres_token

After config configuration.yaml

climate: - platform: smartthinq refresh_token: token

I received error :|

The following components and platforms could not be set up: climate.smartthinq

bmwm69 avatar Apr 03 '18 19:04 bmwm69

Hmm, is there any more detail in the log? That message could mean anything…

sampsyo avatar Apr 03 '18 19:04 sampsyo

2018-04-03 21:35:30 ERROR (SyncWorker_2) [homeassistant.util.package] Unable to install package wideq: Could not find a version that satisfies the requirement wideq (from versions: ) No matching distribution found for wideq 2018-04-03 21:35:30 ERROR (MainThread) [homeassistant.requirements] Not initializing climate.smartthinq because could not install requirement wideq 2018-04-03 21:35:30 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform climate.smartthinq: Could not install all requirements.

bmwm69 avatar Apr 03 '18 20:04 bmwm69

Pip3 Install Log

core-ssh:/wideq# pip3 install -e . Obtaining file:///wideq Collecting requests (from wideq==0.0.0) Downloading requests-2.18.4-py2.py3-none-any.whl (88kB) 100% |████████████████████████████████| 92kB 728kB/s Collecting certifi>=2017.4.17 (from requests->wideq==0.0.0) Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB) 100% |████████████████████████████████| 153kB 585kB/s Collecting chardet<3.1.0,>=3.0.2 (from requests->wideq==0.0.0) Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB) 100% |████████████████████████████████| 143kB 650kB/s Collecting urllib3<1.23,>=1.21.1 (from requests->wideq==0.0.0) Downloading urllib3-1.22-py2.py3-none-any.whl (132kB) 100% |████████████████████████████████| 133kB 636kB/s Collecting idna<2.7,>=2.5 (from requests->wideq==0.0.0) Downloading idna-2.6-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 634kB/s Installing collected packages: certifi, chardet, urllib3, idna, requests, wideq Running setup.py develop for wideq Successfully installed certifi-2018.1.18 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22 wideq

bmwm69 avatar Apr 03 '18 21:04 bmwm69

Strange! I'm not sure what to recommend. It looks like wideq installed correctly, but the Python instance that's running Home Assistant can't find it. I don't know the inner workings of the hass.io image setup, but maybe asking about the issue generically (i.e., dependency installed with pip install -e can't be found when setting up a component) in the HA forums.

sampsyo avatar Apr 03 '18 22:04 sampsyo

Thanks the update. I cleared that problem, and has another problem.... :( I have a climate device, nest, is it related this problem?

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 253, in _async_add_entity
    'Invalid entity id: {}'.format(entity.entity_id))
homeassistant.exceptions.HomeAssistantError: Invalid entity id: climate.

wkd8176 avatar Apr 03 '18 23:04 wkd8176

Sorry; I don't recognize this error. Looks like it's inside the HA code. As in the previous case, it might be best to ask on the HA forums or something.

For posterity, you might also consider recording the solution to your previous problem here.

sampsyo avatar Apr 03 '18 23:04 sampsyo

Oh, i solved the ‘Invalid entity_id’ issue. My AC had korean name so i changed it english in smartthinq app, the error was cleared.

Could you update the readme.md, include command set?

wkd8176 avatar Apr 04 '18 05:04 wkd8176

Actually, in the spirit of open-source collaboration, can you please do it? Please open a PR with the changes you want to see and we’ll go from there.

sampsyo avatar Apr 04 '18 13:04 sampsyo

After install Raspbian all now works fine ! But with application I increase 1ºc by 1ºc, with HA integration temperature increases with strange values 20.8º , 21.3º , 21.8º ..

bmwm69 avatar Apr 05 '18 19:04 bmwm69

Hmm, yes, I've currently hard-coded the plugin to use Fahrenheit, so you're probably seeing rounding errors. This is the relevant line: https://github.com/sampsyo/hass-smartthinq/blob/c5541db7957d5030e8b525e87113d71564bcdd08/smartthinq.py#L43

If you change that to False, you should get Celsius. I should figure out how to make that a configurable option…

sampsyo avatar Apr 05 '18 19:04 sampsyo

@bmwm69 (@sampsyo)

I have the same problem as you ... but I'm using Raspbian and not Hass.io

"2018-04-03 21:35:30 ERROR (SyncWorker_2) [homeassistant.util.package] Unable to install package wideq: Could not find a version that satisfies the requirement wideq (from versions: ) No matching distribution found for wideq 2018-04-03 21:35:30 ERROR (MainThread) [homeassistant.requirements] Not initializing climate.smartthinq because could not install requirement wideq 2018-04-03 21:35:30 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform climate.smartthinq: Could not install all requirements."

How did you solve your problem? Installing and using Raspbian instead Hass.io?

Have you installed wideq in the root folder?

Pharizna avatar Jun 27 '18 17:06 Pharizna

Help, please :)

Pharizna avatar Jul 05 '18 17:07 Pharizna

Hi, @Pharizna—posting updates like this, or the one in https://github.com/sampsyo/hass-smartthinq/issues/6#issuecomment-402801885, is not helpful. We (the community) have already weighed in and helped however we could—we didn't just forget about the thread. Please try asking elsewhere and updating here if you learn anything useful.

sampsyo avatar Jul 05 '18 18:07 sampsyo

Sorry :(

Pharizna avatar Jul 05 '18 18:07 Pharizna

Solved :)

$ sudo su -s /bin/bash homeassistant $ source /srv/homeassistant/bin/activate

$ git clone https://github.com/sampsyo/wideq.git $ cd wideq $ pip3 install -e .

((wideq folder owner has to be homeassistant, of course))

image

Pharizna avatar Jul 10 '18 07:07 Pharizna

https://github.com/sampsyo/hass-smartthinq/issues/1#issuecomment-403733310 Is this done using Hass.io?

ctih avatar Feb 25 '19 23:02 ctih