Python Plugin: LG Smart AC (SmartThinQ) Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
johnny86
Posts: 7
Joined: Sunday 24 January 2021 20:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 13872
Location: PL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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 :)
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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.
johnny86
Posts: 7
Joined: Sunday 24 January 2021 20:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 13872
Location: PL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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:)
User avatar
heggink
Posts: 978
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
User avatar
heggink
Posts: 978
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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).
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
johnny86
Posts: 7
Joined: Sunday 24 January 2021 20:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 13872
Location: PL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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
User avatar
heggink
Posts: 978
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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...
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
johnny86
Posts: 7
Joined: Sunday 24 January 2021 20:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 13872
Location: PL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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
User avatar
heggink
Posts: 978
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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.
Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
johnny86
Posts: 7
Joined: Sunday 24 January 2021 20:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 13872
Location: PL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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:)
nicky
Posts: 2
Joined: Monday 17 May 2021 16:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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)
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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?
User avatar
heggink
Posts: 978
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by heggink »

Same here: works fine...

Sent from my SM-G980F using Tapatalk

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
nicky
Posts: 2
Joined: Monday 17 May 2021 16:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by nicky »

Tnx for checking guys. I have renewed the token and now it seems to be working again :D
gvrgvr
Posts: 17
Joined: Friday 09 October 2020 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Netherlands
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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?
User avatar
heggink
Posts: 978
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
gvrgvr
Posts: 17
Joined: Friday 09 October 2020 8:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Netherlands
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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.
majki
Posts: 21
Joined: Monday 19 July 2021 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Krakow, PL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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.
User avatar
waltervl
Posts: 5727
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
heggink
Posts: 978
Joined: Tuesday 08 September 2015 21:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 12451
Location: NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post 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

Docker in Truenas scale, close to latest beta
DASHTICZ 🙃
RFXCOM, zwavejs2mqtt, zigbee2mqtt,
P1 meter & solar panel
Google home, Wifi Cams motion detection
Geofence iCloud, Bluetooth & Wifi ping
Harmony hub, Nest, lots more :-)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest