Page 5 of 9

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 24 January 2021 20:03
by johnny86
some progress?
Has anyone tried to repair the plug?
I include a working script

https://github.com/sampsyo/wideq


nice if someone adapted it to domoticz :)

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 24 January 2021 22:59
by javalin
johnny86 wrote: Sunday 24 January 2021 20:03 some progress?
This plugin is fully working for wideq v1. The problem is if you need wideq v2 library to log, is not still developed and this plugin also not ready.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 25 January 2021 10:28
by johnny86
thanks for the info.
Through https://github.com/sampsyo/wideq I can, for example, turn on the air conditioning.
Unfortunately, something is not working for me https://github.com/heggink/LGAC_SmartT :(
maybe because I already have python 3.7?
It normally displays refresh_token and AC Device Number



On trial
python3 ./LGACServerNew.py
I have
Image


if I give
sudo python3 testServer.py

Image


can anyone help? I will be very grateful:)

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 25 January 2021 11:16
by heggink
I'll have a look in a bit if I can spot anything. I also have 3.7 so that should not be the culprit.

Sent from my SM-G980F using Tapatalk


Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 25 January 2021 11:42
by heggink
johnny86 wrote: Monday 25 January 2021 10:28 thanks for the info.
Through https://github.com/sampsyo/wideq I can, for example, turn on the air conditioning.
Unfortunately, something is not working for me https://github.com/heggink/LGAC_SmartT :(
maybe because I already have python 3.7?
It normally displays refresh_token and AC Device Number



On trial
python3 ./LGACServerNew.py
I have
Image


if I give
sudo python3 testServer.py

Image


can anyone help? I will be very grateful:)
Address in use normally means that something is already listening on that port so please check. Also, can you let me know what you have done up to that point? Was everything correctly installed (sudo pip3 install -e . and wideq.py data edited, what do you get if you issue python3 example.py ls and so on).

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 25 January 2021 11:59
by johnny86
ok

my mistake because I ran lgac_server
Address in use normally means that something is already listening on that port so please check. Also, can you let me know what you have done up to that point? Was everything correctly installed (sudo pip3 install -e . and wideq.py data edited, what do you get if you issue python3 example.py ls and so on).

sudo systemctl stop lgac_server
Now I have

Image
tried to change port but it didn't help - same error

Image


wideq.py didn't edit, only LGACServerNew.py
GATEWAY_URL = 'https://kic.lgthinq.com:46030/api/common/gatewayUriList'
APP_KEY = 'wideq'
SECURITY_KEY = 'nuts_securitykey'
DATA_ROOT = 'lgedmRoot'
COUNTRY = 'PL'
LANGUAGE = 'en-EN'
SVC_CODE = 'SVC202'
CLIENT_ID = 'LGAO221A02'
OAUTH_SECRET_KEY = 'c053c2a6ddeb7ad97cb0eed0dcb31cf8'
OAUTH_CLIENT_KEY = 'LGAO221A02'
DATE_FORMAT = '%a, %d %b %Y %H:%M:%S +0000'

after changing the port and rebooting it is a little better
Image
I don't know if it was supposed to be like that, but it's only a few minutes;)


UPDATE

I stopped at it
Image

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 25 January 2021 13:13
by heggink
johnny86 wrote: Monday 25 January 2021 11:59 ok

my mistake because I ran lgac_server
Address in use normally means that something is already listening on that port so please check. Also, can you let me know what you have done up to that point? Was everything correctly installed (sudo pip3 install -e . and wideq.py data edited, what do you get if you issue python3 example.py ls and so on).

sudo systemctl stop lgac_server
Now I have

Image
tried to change port but it didn't help - same error

Image


wideq.py didn't edit, only LGACServerNew.py
GATEWAY_URL = 'https://kic.lgthinq.com:46030/api/common/gatewayUriList'
APP_KEY = 'wideq'
SECURITY_KEY = 'nuts_securitykey'
DATA_ROOT = 'lgedmRoot'
COUNTRY = 'PL'
LANGUAGE = 'en-EN'
SVC_CODE = 'SVC202'
CLIENT_ID = 'LGAO221A02'
OAUTH_SECRET_KEY = 'c053c2a6ddeb7ad97cb0eed0dcb31cf8'
OAUTH_CLIENT_KEY = 'LGAO221A02'
DATE_FORMAT = '%a, %d %b %Y %H:%M:%S +0000'

after changing the port and rebooting it is a little better
Image
I don't know if it was supposed to be like that, but it's only a few minutes;)


UPDATE

I stopped at it
Image
OK, so when you say "wideq didn't edit", I did not create this plugin but worked on it in order to get it functioning again. I also just copied the installation instructions. In my case, I changed wideq.py to change the country to NL but not sure if that would make a difference. Did you also run this part of the installation instructions?

Code: Select all

Authenticate with the SmartThing service to get a refresh token by running the WideQ example script.Run this in the wideq directory:
sudo python3 example.py
The script will ask you to open a browser, log in, and then paste the URL you're redirected to. It will then write a JSON file called wideq_state.json.
Look inside this file for a key called "refresh_token" and copy the value.
Since my pi is headless, I needed to do that on a different system...

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 25 January 2021 15:35
by johnny86
little progress :)


I can already control the air conditioning via domoticz

I have two more problems

1. Doesn't show temperature. In logs, I see values ​​for b'temp_actual
Image
2021-01-25 15:36:26.399 (Klimatyzacja) Got: {b'state': b'off', b'mode': b'COOL', b'temp_actual': b'23.5', b'temp_setpoint': b'18', b'wind_strength': b'6', b'air_ionizer': b'0', b'cmd': b'status'}
2. Minor problem but may cause problem with ptk
2021-01-25 15:27:26.312 Error: Python Plugin System: (Klimatyzacja) 'onMessage' failed 'KeyError'.
2021-01-25 15:27:26.312 Error: Python Plugin System: (Klimatyzacja) ----> Line 336 in '/home/pi/domoticz/plugins/LG-SThinq-AC/plugin.py', function onMessage
2021-01-25 15:27:26.312 Error: Python Plugin System: (Klimatyzacja) ----> Line 129 in '/home/pi/domoticz/plugins/LG-SThinq-AC/plugin.py', function onMessage

Image

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 25 January 2021 16:35
by heggink
That's weird. One of the things I had to change was the pack/unpack routine as there were some changes in the msgpack library that broke this plugin. I didn't change the original installation wiki which may cause this issue since I believe msgpack-python is depreciated and msgpack should be installed. Can you check which one you installed? From your log, you can see that every field (and value) has a 'b' in front of it which is wrong. If that gets fixed, it should work.
You can try: sudo pip3 uninstall msgpack-python followed by a sudo pip3 install -U msgpack

Let me know.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Tuesday 26 January 2021 10:36
by johnny86
unfortunately but sudo pip3 uninstall msgpack-python followed by a sudo pip3 install -U msgpack
did not help

I don't know what's up in me,
i don't know python but i found something


if in LGACServerNew.py I have

line 70/71
# unpacker = Unpacker(encoding='utf-8')
unpacker = Unpacker()
Image
in domoticz, nothing works for me, e.g. 'cmd': b'status, etc.

if in LGACServerNew.py I have
unpacker = Unpacker(encoding='utf-8')
#unpacker = Unpacker()
In ssh is ok,
Image


in domoticz I run and turn off the air conditioning only there is no home temperature and the logs show "b", interestingly in ssh


I don't know what I have mixed up in the system that I have to have unpacker = Unpacker (encoding = 'utf-8')

I have to look for a domoticz plug in the code and probably also change it, but I don't know where ...

Update
i change in plugin.py
self.unpacker = msgpack.Unpacker(encoding='utf-8')
It helped me :) I don't know why it has to be utf-8, but most importantly, it works:)

Thank you for your help:)

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 17 May 2021 16:11
by nicky
Anyone else having trouble controlling LG AC devices with this plugin at the moment? Plugin worked fine for more than a year (also worked with Domoticz 2021.1) but suddenly stopped syncing since last week. Devices don't get updated anymore and On/Off device switches of the AC's don't work...

When i stop and manually start the LGACServerNew.py I can see Domoticz requests but then the connection immediatly closes (instead of getting the results)

server: Starting server on 127.0.0.1 22233
server: connected ('127.0.0.1', 51744)
server: got socket msg: ['check_Filter']
server: got socket msg: ['status']
server: closed connection ('127.0.0.1', 51744)

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Thursday 20 May 2021 16:35
by javalin
Hello, my plugin is working correctly
When i stop and manually start the LGACServerNew.py I can see Domoticz requests but then the connection immediatly closes
Have you checked your token? May be has expired?

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Thursday 20 May 2021 21:37
by heggink
Same here: works fine...

Sent from my SM-G980F using Tapatalk


Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 22 May 2021 12:51
by nicky
Tnx for checking guys. I have renewed the token and now it seems to be working again :D

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Thursday 08 July 2021 15:51
by gvrgvr
I tried several times to install this plugin, also the new fork (heggink), but no luck. I keep getting the error "KeyError: 'item'" that's mentioned multiple times in this topic, after executing "sudo python3 example.py"

Has anyone got this working on a raspberry pi with Raspbian buster?

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Thursday 08 July 2021 16:01
by heggink
I do . I can try to help debug. I have a test system these days so let's see. Start by switching on all debugging and pm me with the data.

Sent from my SM-G980F using Tapatalk


Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 10 July 2021 7:57
by gvrgvr
heggink wrote: Thursday 08 July 2021 16:01 I do Image. I can try to help debug. I have a test system these days so let's see. Start by switching on all debugging and pm me with the data.

Sent from my SM-G980F using Tapatalk
Great! Will do asap.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 19 July 2021 15:06
by majki
Hi. I have developed LG ThinQ domoticz plugin for v2 API. It's working with my Air Conditioner (PC12SQ).
What should I do to get this submitted to official plugin list on wiki? I tried to PM warren, but I can't and it seems that my account needs more reputation.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 19 July 2021 15:17
by waltervl
majki wrote: Monday 19 July 2021 15:06 Hi. I have developed LG ThinQ domoticz plugin for v2 API. It's working with my Air Conditioner (PC12SQ).
What should I do to get this submitted to official plugin list on wiki? I tried to PM warren, but I can't and it seems that my account needs more reputation.
Just put a link to your github repository here and i will add it to the Wiki plugins page.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Monday 19 July 2021 16:07
by heggink
majki wrote:Hi. I have developed LG ThinQ domoticz plugin for v2 API. It's working with my Air Conditioner (PC12SQ).
What should I do to get this submitted to official plugin list on wiki? I tried to PM warren, but I can't and it seems that my account needs more reputation.
Excellent news. Is this compatible with the v1 logins as well? What is your GitHub repo? Love to see it.
Great work. Many thanks.

Sent from my SM-G980F using Tapatalk