Page 3 of 9

Re: Python Plugin: LG Smart AC (SmartThinQ) - SOLVED

Posted: Friday 23 October 2020 22:50
by heggink
Thierry33700 wrote: Sunday 04 October 2020 12:23
stingone wrote: Saturday 27 June 2020 21:51
Thierry33700 wrote: Sunday 03 November 2019 15:41

Hello luckymr2201,
Thanks for your help, unfortunately i was not able to go next step, i created a wideq_state.json file like follow :

"{
"access_token": "1ca3e111112234e543cfada616f65ee60493d136640adc1e1f841989a7fe9cf3350594da1c6ae485e6e6e8182f4f42451d",
"refresh_token": "194be3b7596111111a5eb8ee484e180d3adb4644a63fc4f8ce9709e3f1c696fb20d1329e022d56daab51ac820893bd7",
"oauth2_backend_url": "https://gb.lgeapi.com/"
}
"
But i had the same issue when running 'python3 example.py ls' :

Traceback (most recent call last):
File "example.py", line 214, in <module>
example(sys.argv[1:])
File "example.py", line 200, in example
example_command(client, args)
File "example.py", line 180, in example_command
func(client, *args[1:])
File "example.py", line 25, in ls
for device in client.devices:
File "/root/LGAC_SmartT/wideq.py", line 474, in devices
self._devices = self.session.get_devices()
File "/root/LGAC_SmartT/wideq.py", line 465, in session
self._session, self._devices = self.auth.start_session()
File "/root/LGAC_SmartT/wideq.py", line 257, in start_session
return Session(self, session_id), as_list(session_info['item'])
KeyError: 'item'


Can't go further. Hope someone has the same issue and help ;-)

Thx.
Thierry
How did you solve this? get the same error. With both Buster and Stretch
Hi,
After lot of several new tests, i succeded. Here is what i did to make it work.
First, i deleted /home/pi/LGAC_SmartT folder:
sudo rm -rf LGAC_SmartT/

then i choosed fork from https://github.com/heggink/LGAC_SmartT. - Thanks to heggink !!!
I followed mostly his installation process, get the same problem ... BUT then i had the idea to change this line in the installation process :

python3 example.py

was changed into
sudo python3 example.py

then everything worked for the server.

Then in domoticz, i get the following errors in domoticz's logs :
...
2020-10-04 11:42:09.327 Error: (LG-SmartThinq-AC) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/LG-SThinq-AC/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2020-10-04 11:42:09.328 Error: (Clim_Salon) Module Import failed, exception: 'AttributeError'
2020-10-04 11:42:09.328 Error: (Clim_Salon) Error Line details not available.
2020-10-04 11:43:20.329 Error: Clim_Salon hardware (7) thread seems to have ended unexpectedly
..
I found a similar issue there : https://github.com/mrin/domoticz-mirobo ... /issues/26

So i followed to type :
sudo pip3 install -U --ignore-installed msgpack=="0.6.2"

Then domoticz started to use the plugin !!

Next i'll add others Climatisers by creating duplications of the server scripts as explain.
And i will now prepare or look for a script to manage start and stop within a given temperature in the room.

Thanks to all developpers that worked on this.

Thierry
Hey Thierry,

It's weird that you had to revert to msgpack 0.6.2 as I run 1.0.0. with no problems... Which OS/version are you running? From the above, I would suspect the latest raspbian, right?

I 'only' made a bunch of changes to olinek2's plugin to make it work for me but I am hardly the new maintainer. If anyone wants to help maintain this and develop on top of my changes, be my guest. I have no plans to buy other LG stuff for now (no need).

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 25 October 2020 9:06
by javalin
Good morning,

I get this error with the plugin, someone know whats means?

Error: CConnection_connect, connect request from 'AC_Sala' ignored. Transport is connected.
Capture.JPG
Capture.JPG (45.08 KiB) Viewed 3939 times
Kind regards

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 25 October 2020 9:12
by javalin
Devious wrote: Wednesday 14 October 2020 21:53 I'm still getting the same error

...
7&oauth2_backend_url=https://gb.lgeapi.com/
Traceback (most recent call last):
File "example.py", line 214, in <module>
example(sys.argv[1:])
File "example.py", line 200, in example
example_command(client, args)
File "example.py", line 177, in example_command
ls(client)
File "example.py", line 25, in ls
for device in client.devices:
File "/home/pi/LGAC_SmartT/wideq.py", line 474, in devices
self._devices = self.session.get_devices()
File "/home/pi/LGAC_SmartT/wideq.py", line 465, in session
self._session, self._devices = self.auth.start_session()
File "/home/pi/LGAC_SmartT/wideq.py", line 257, in start_session
return Session(self, session_id), as_list(session_info['item'])
KeyError: 'item'
pi@raspberrypi:~/LGAC_SmartT $

I used the sudo python3 example.py

anyone else?
You have a login problem, check if yor loggin settings are the same from LG ThinQ App and https://pt.m.lgaccount.com/login...
Avoid sign in with google account
Capture.JPG
Capture.JPG (99.75 KiB) Viewed 3937 times

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 25 October 2020 9:13
by heggink
I have seen those as well. It looks like the plugin tries to connect when it's already connected. I tried to locate that message and fix but haven't managed so far. Since it does not impact the functioning of the plugin, fixing it is low in my prio list especially since this isn't my plugin to begin with .

Sent from my SM-G980F using Tapatalk


Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 25 October 2020 10:17
by javalin
Thank you Heggink,

In my case the plugin don´t wotk. Looking into my log, I think it fails at start and after that reconnect but there is no reponse from domoticz commands.

2020-10-25 09:08:20.059 (AC_Sala) Pushing 'onHeartbeatCallback' on to queue
2020-10-25 09:08:20.087 (AC_Sala) Processing 'onHeartbeatCallback' message
2020-10-25 09:08:20.087 (AC_Sala) Calling message handler 'onHeartbeat'.
2020-10-25 09:08:20.087 (AC_Sala) Pushing 'WriteDirective' on to queue
2020-10-25 09:08:20.087 (AC_Sala) Pushing 'WriteDirective' on to queue
2020-10-25 09:08:20.087 (AC_Sala) Pushing 'DisconnectDirective' on to queue
2020-10-25 09:08:20.088 (AC_Sala) Processing 'WriteDirective' message
2020-10-25 09:08:20.088 (AC_Sala) Sending 14 bytes of data
2020-10-25 09:08:20.088 (AC_Sala) 91 ac 63 68 65 63 6b 5f 46 69 6c 74 65 72 .. .. .. .. .. .. Ѭcheck_Filter
2020-10-25 09:08:20.090 (AC_Sala) Processing 'WriteDirective' message
2020-10-25 09:08:20.090 (AC_Sala) Sending 8 bytes of data
2020-10-25 09:08:20.090 (AC_Sala) 91 a6 73 74 61 74 75 73 .. .. .. .. .. .. .. .. .. .. .. .. Ѧstatus
2020-10-25 09:08:20.091 (AC_Sala) Processing 'DisconnectDirective' message
2020-10-25 09:08:20.091 (AC_Sala) Disconnect directive received for '127.0.0.1:22233'.
2020-10-25 09:08:20.091 (AC_Sala) Handling TCP disconnect, socket (127.0.0.1:22233) is connected
2020-10-25 09:08:20.094 (AC_Sala) Queued asynchronous read aborted (127.0.0.1:22233), [2] End of file.
2020-10-25 09:08:20.094 (AC_Sala) Pushing 'DisconnectedEvent' on to queue
2020-10-25 09:08:20.094 (AC_Sala) Processing 'DisconnectedEvent' message
2020-10-25 09:08:20.094 (AC_Sala) Disconnect event received for '127.0.0.1:22233'.
2020-10-25 09:08:20.094 (AC_Sala) Pushing 'onDisconnectCallback' on to queue
2020-10-25 09:08:20.094 (AC_Sala) Processing 'onDisconnectCallback' message
2020-10-25 09:08:20.094 (AC_Sala) Calling message handler 'onDisconnect'.
2020-10-25 09:08:20.094 (AC_Sala) LGAC onDisconnect called
2020-10-25 09:08:20.087 Error: CConnection_connect, connect request from 'AC_Sala' ignored. Transport is connected.

2020-10-25 09:09:20.071 (AC_Sala) Pushing 'onHeartbeatCallback' on to queue
2020-10-25 09:09:20.114 (AC_Sala) Processing 'onHeartbeatCallback' message
2020-10-25 09:09:20.114 (AC_Sala) Calling message handler 'onHeartbeat'.
2020-10-25 09:09:20.114 (AC_Sala) Pushing 'ConnectDirective' on to queue
2020-10-25 09:09:20.114 (AC_Sala) Trying connect to LGACServer 127.0.0.1:22233
2020-10-25 09:09:20.114 (AC_Sala) Processing 'ConnectDirective' message
2020-10-25 09:09:20.114 (AC_Sala) Transport set to: 'TCP/IP', 127.0.0.1:22233.
2020-10-25 09:09:20.117 (AC_Sala) Connect directive received, action initiated successfully.
2020-10-25 09:09:20.120 (AC_Sala) Pushing 'onConnectCallback' on to queue
2020-10-25 09:09:20.167 (AC_Sala) Processing 'onConnectCallback' message
2020-10-25 09:09:20.167 (AC_Sala) Calling message handler 'onConnect'.
2020-10-25 09:09:20.167 (AC_Sala) LGACServer connection status is [0] [Success]

2020-10-25 09:13:05.113 (AC_Sala) Pushing 'onHeartbeatCallback' on to queue
2020-10-25 09:13:05.143 (AC_Sala) Processing 'onHeartbeatCallback' message
2020-10-25 09:13:05.143 (AC_Sala) Calling message handler 'onHeartbeat'.
2020-10-25 09:13:20.117 (AC_Sala) Pushing 'onHeartbeatCallback' on to queue
2020-10-25 09:13:20.119 (AC_Sala) Processing 'onHeartbeatCallback' message
2020-10-25 09:13:20.119 (AC_Sala) Calling message handler 'onHeartbeat'.
2020-10-25 09:13:20.119 (AC_Sala) Pushing 'WriteDirective' on to queue
2020-10-25 09:13:20.119 (AC_Sala) Processing 'WriteDirective' message
2020-10-25 09:13:20.119 (AC_Sala) Sending 8 bytes of data
2020-10-25 09:13:20.120 (AC_Sala) 91 a6 73 74 61 74 75 73 .. .. .. .. .. .. .. .. .. .. .. .. Ѧstatus

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Tuesday 27 October 2020 20:42
by Devious
javalin wrote: Sunday 25 October 2020 9:12
Devious wrote: Wednesday 14 October 2020 21:53 I'm still getting the same error

...
7&oauth2_backend_url=https://gb.lgeapi.com/
Traceback (most recent call last):
File "example.py", line 214, in <module>
example(sys.argv[1:])
File "example.py", line 200, in example
example_command(client, args)
File "example.py", line 177, in example_command
ls(client)
File "example.py", line 25, in ls
for device in client.devices:
File "/home/pi/LGAC_SmartT/wideq.py", line 474, in devices
self._devices = self.session.get_devices()
File "/home/pi/LGAC_SmartT/wideq.py", line 465, in session
self._session, self._devices = self.auth.start_session()
File "/home/pi/LGAC_SmartT/wideq.py", line 257, in start_session
return Session(self, session_id), as_list(session_info['item'])
KeyError: 'item'
pi@raspberrypi:~/LGAC_SmartT $

I used the sudo python3 example.py

anyone else?
You have a login problem, check if yor loggin settings are the same from LG ThinQ App and https://pt.m.lgaccount.com/login...
Avoid sign in with google account
Capture.JPG
I did a password reset and logged in the LG ThinQ App with the new password.
Ran sudo pyton3 example.py again. still the same results :-(
https://pt.m.lgaccount.com/login... would be https://nl.m.lgaccount.com/login... for me because im in the Netherlands right?

Anyone else in the Netherlands that has this working?

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Tuesday 27 October 2020 22:11
by javalin
Devious wrote: Tuesday 27 October 2020 20:42
javalin wrote: Sunday 25 October 2020 9:12
Devious wrote: Wednesday 14 October 2020 21:53 I'm still getting the same error

...
7&oauth2_backend_url=https://gb.lgeapi.com/
Traceback (most recent call last):
File "example.py", line 214, in <module>
example(sys.argv[1:])
File "example.py", line 200, in example
example_command(client, args)
File "example.py", line 177, in example_command
ls(client)
File "example.py", line 25, in ls
for device in client.devices:
File "/home/pi/LGAC_SmartT/wideq.py", line 474, in devices
self._devices = self.session.get_devices()
File "/home/pi/LGAC_SmartT/wideq.py", line 465, in session
self._session, self._devices = self.auth.start_session()
File "/home/pi/LGAC_SmartT/wideq.py", line 257, in start_session
return Session(self, session_id), as_list(session_info['item'])
KeyError: 'item'
pi@raspberrypi:~/LGAC_SmartT $

I used the sudo python3 example.py

anyone else?
You have a login problem, check if yor loggin settings are the same from LG ThinQ App and https://pt.m.lgaccount.com/login...
Avoid sign in with google account
Capture.JPG
I did a password reset and logged in the LG ThinQ App with the new password.
Ran sudo pyton3 example.py again. still the same results :-(
https://pt.m.lgaccount.com/login... would be https://nl.m.lgaccount.com/login... for me because im in the Netherlands right?

Anyone else in the Netherlands that has this working?
Yes, your link must begin with https://nl.m.lgaccount.com/login...because you are logged from there.

To fix your error try run this comand:

sudo sed -i "s|TLSv1.2|TLSv1.0|g" /etc/ssl/openssl.cnf

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Thursday 29 October 2020 20:08
by Devious
javalin wrote: Tuesday 27 October 2020 22:11
Devious wrote: Tuesday 27 October 2020 20:42
javalin wrote: Sunday 25 October 2020 9:12

You have a login problem, check if yor loggin settings are the same from LG ThinQ App and https://pt.m.lgaccount.com/login...
Avoid sign in with google account
Capture.JPG
I did a password reset and logged in the LG ThinQ App with the new password.
Ran sudo pyton3 example.py again. still the same results :-(
https://pt.m.lgaccount.com/login... would be https://nl.m.lgaccount.com/login... for me because im in the Netherlands right?

Anyone else in the Netherlands that has this working?
Yes, your link must begin with https://nl.m.lgaccount.com/login...because you are logged from there.

To fix your error try run this comand:

sudo sed -i "s|TLSv1.2|TLSv1.0|g" /etc/ssl/openssl.cnf

Code: Select all

pi@raspberrypi:~/LGAC_SmartT $ sudo sed -i "s|TLSv1.2|TLSv1.0|g" /etc/ssl/openssl.cnf
pi@raspberrypi:~/LGAC_SmartT $ sudo python3 example.py
Log in here:
https://nl.m.lgaccount.com/login/sign_in?country=NL&language=en-EN&svcCode=SVC202&authSvr=oauth2&client_id=LGAO221A02&division=ha&grant_type=password
Then paste the URL where the browser is redirected:
https://nl.m.lgaccount.com/login/iabClose?access_token=*************************&refresh_token=*******************&oauth2_backend_url=https://gb.lgeapi.com/
Traceback (most recent call last):
  File "example.py", line 214, in <module>
    example(sys.argv[1:])
  File "example.py", line 200, in example
    example_command(client, args)
  File "example.py", line 177, in example_command
    ls(client)
  File "example.py", line 25, in ls
    for device in client.devices:
  File "/home/pi/LGAC_SmartT/wideq.py", line 478, in devices
    self._devices = self.session.get_devices()
  File "/home/pi/LGAC_SmartT/wideq.py", line 469, in session
    self._session, self._devices = self.auth.start_session()
  File "/home/pi/LGAC_SmartT/wideq.py", line 261, in start_session
    return Session(self, session_id), as_list(session_info['item'])
KeyError: 'item'
pi@raspberrypi:~/LGAC_SmartT $ 
still get the same results :-(
tried the the command at the start but had no luck, and then tried it before " sudo python example.py" but still the same.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 08 November 2020 21:48
by pietje1951
Hello, I am a beginner with a raspberry pi and Domoticz.
I have a LG AC and would like to instruct my AC with domoticz.
Is there a simple way to get that done ?
I don't know to program in Python
Thanks !

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Sunday 08 November 2020 21:52
by heggink
You don't need to programme in python, just follow the installation commands in the wiki.

Sent from my SM-G980F using Tapatalk


Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Thursday 19 November 2020 22:11
by pietje1951
Hello,

I am a beginner with the raspberry pi 4.
I have a LG airconditioner and i control it with the app on my phone. That goes well.
But I like to integrate the LG in domoticz.
Does this plugin work ?
And is it to do for a beginner ?


Piet Spoelstra

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Thursday 19 November 2020 22:48
by heggink
Depends on the beginner bit: can you execute commands from a shell? If so then follow the instructions and post here if you get stuck. I don't have a pi4 but see no reason why it shouldn't work...

Sent from my SM-G980F using Tapatalk


Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Friday 20 November 2020 16:30
by pietje1951
My efforts: I think the last lines are not correct, is that true. What did I do wrong ?

Microsoft Windows [Version 10.0.19042.630]
(c) 2020 Microsoft Corporation. Alle rechten voorbehouden.

C:\Users\Gebruiker>ssh [email protected]
[email protected]'s password:
Linux raspberrypi 5.4.72-v7l+ #1356 SMP Thu Oct 22 13:57:51 BST 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Nov 19 12:42:59 2020
pi@raspberrypi:~ $ sudo apt-get install python3 python3-dev python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version (3.7.3-1).
python3-dev is already the newest version (3.7.3-1).
python3-dev set to manually installed.
python3-pip is already the newest version (18.1-5+rpt1).
The following packages were automatically installed and are no longer required:
libmicrodns0 rpi-eeprom-images
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@raspberrypi:~ $ sudo apt-get install libffi-dev libssl-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libmicrodns0 rpi-eeprom-images
Use 'sudo apt autoremove' to remove them.
Suggested packages:
libssl-doc
The following NEW packages will be installed:
libffi-dev libssl-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,742 kB of archives.
After this operation, 6,269 kB of additional disk space will be used.
Get:1 http://archive.raspberrypi.org/debian buster/main armhf libssl-dev armhf 1.1.1d-0+deb10u3+rpt1 [1,583 kB]
Get:2 http://mirror.transip.net/raspbian/raspbian buster/main armhf libffi-dev armhf 3.2.1-9 [159 kB]
Fetched 1,742 kB in 2s (979 kB/s)
Selecting previously unselected package libffi-dev:armhf.
(Reading database ... 100324 files and directories currently installed.)
Preparing to unpack .../libffi-dev_3.2.1-9_armhf.deb ...
Unpacking libffi-dev:armhf (3.2.1-9) ...
Selecting previously unselected package libssl-dev:armhf.
Preparing to unpack .../libssl-dev_1.1.1d-0+deb10u3+rpt1_armhf.deb ...
Unpacking libssl-dev:armhf (1.1.1d-0+deb10u3+rpt1) ...
Setting up libffi-dev:armhf (3.2.1-9) ...
Setting up libssl-dev:armhf (1.1.1d-0+deb10u3+rpt1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for install-info (6.5.0.dfsg.1-4+b1) ...
pi@raspberrypi:~ $ sudo pip3 install -U setuptools
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting setuptools
Downloading https://files.pythonhosted.org/packages ... ne-any.whl (785kB)
100% |████████████████████████████████| 788kB 556kB/s
Installing collected packages: setuptools
Found existing installation: setuptools 40.8.0
Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'setuptools'. No files were found to uninstall.
Successfully installed setuptools-50.3.2
pi@raspberrypi:~ $ sudo pip3 install gevent msgpack-python greenlet
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting gevent
Downloading https://www.piwheels.org/simple/gevent/ ... armv7l.whl (5.1MB)
100% |████████████████████████████████| 5.1MB 90kB/s
Collecting msgpack-python
Downloading https://www.piwheels.org/simple/msgpack ... armv7l.whl (339kB)
100% |████████████████████████████████| 348kB 1.3MB/s
Collecting greenlet
Downloading https://www.piwheels.org/simple/greenle ... armv7l.whl (47kB)
100% |████████████████████████████████| 51kB 3.7MB/s
Collecting zope.interface (from gevent)
Downloading https://www.piwheels.org/simple/zope-in ... armv7l.whl (225kB)
100% |████████████████████████████████| 235kB 1.8MB/s
Collecting zope.event (from gevent)
Downloading https://files.pythonhosted.org/packages ... ne-any.whl
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from gevent) (50.3.2)
Installing collected packages: greenlet, zope.interface, zope.event, gevent, msgpack-python
Successfully installed gevent-20.9.0 greenlet-0.4.17 msgpack-python-0.5.6 zope.event-4.5.0 zope.interface-5.2.0
pi@raspberrypi:~ $ $ git clone https://github.com/olinek2/LGAC_SmartT
-bash: $: command not found
pi@raspberrypi:~ $ git clone https://github.com/olinek2/LGAC_SmartT
Cloning into 'LGAC_SmartT'...
remote: Enumerating objects: 33, done.
remote: Total 33 (delta 0), reused 0 (delta 0), pack-reused 33
Unpacking objects: 100% (33/33), done.
pi@raspberrypi:~ $ cd LGAC_SmartT
pi@raspberrypi:~/LGAC_SmartT $ sudo pip3 install -e

Usage:
pip3 install [options] <requirement specifier> [package-index-options] ...
pip3 install [options] -r <requirements file> [package-index-options] ...
pip3 install [options] [-e] <vcs project url> ...
pip3 install [options] [-e] <local project path> ...
pip3 install [options] <archive url/path> ...

-e option requires 1 argument
pi@raspberrypi:~/LGAC_SmartT $

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Friday 20 November 2020 16:43
by heggink
OK, making progress :-).

Couple of things you need to change:
1) don't install the original plugin my my cloned version instead. The old one had a couple of issues that I fixed including some msgpack changes that were not compatible with the old one:
Delete the installed folder LGAC_SmartT: sudo rm -r LGAC_SmartT
Install my updated plugin: git clone https://github.com/heggink/LGAC_SmartT

2) then, on the next command, you are missing a period (punt) at the end so the command should be:
sudo pip3 install -e .

Then you can pick up the rest of the installation.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 21 November 2020 10:44
by pietje1951
Thank you for your comment.
I have come a bit further.
Now I am stuck here. What has gone wrong ?
Hope to hear from you !

Piet Spoelstra


Successfully installed wideq
pi@raspberrypi:~/LGAC_SmartT $ nano wideq.py
pi@raspberrypi:~/LGAC_SmartT $ sudo python3 example.py
Session expired.
d27bb3f0-7149-11d3-80af-7440bec3b009: AIRCONDITIONER (AC RAC_056905_WW)
pi@raspberrypi:~/LGAC_SmartT $ wideq_state.json
-bash: wideq_state.json: command not found
pi@raspberrypi:~/LGAC_SmartT $ python3 example.py ls
d27bb3f0-7149-11d3-80af-7440bec3b009: AIRCONDITIONER (AC RAC_056905_WW)
Traceback (most recent call last):
File "example.py", line 214, in <module>
example(sys.argv[1:])
File "example.py", line 209, in example
with open(STATE_FILE, 'w') as f:
PermissionError: [Errno 13] Permission denied: 'wideq_state.json'
pi@raspberrypi:~/LGAC_SmartT $ nano LGACServerNew.py
pi@raspberrypi:~/LGAC_SmartT $ pi@raspberrypi:~/LGAC_SmartT $ sudo chmod +x LGACServerNew.py
pi@raspberrypi:~/LGAC_SmartT $ ./LGACServerNew.py
./LGACServerNew.py: line 1: import: command not found
./LGACServerNew.py: line 2: import: command not found
./LGACServerNew.py: line 4: syntax error near unexpected token `('
./LGACServerNew.py: line 4: `module_paths = [x[0] for x in os.walk( os.path.join(os.path.dirname(__file__), '.', '.env/lib/') ) if x[0].endswith('site-packages') ]'
pi@raspberrypi:~/LGAC_SmartT $

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 21 November 2020 11:03
by heggink
OK, more progress which is good. By the looks of it, after issuing the "pip install -e ." command, everything got installed properly, correct? (no error messages)..

what changes did you make when you did the "nano wideq.py" command? nano is an editor that lets you edit wideq.py. In wideq.py, you need to make some changes that will allow the plugin to access your airconditioner. In my case I needed to make the following changes:
COUNTRY = 'NL'
LANGUAGE = 'en-EN'
OAUTH_SECRET_KEY = 'you need to fill in your specific key'

The key above (login authentication for the LG smartthinq service) and the device number (identifying your Airco) you can get by following the instructions on the plugin page:

python3 example.py
open browser, log in , ...

easiest if you can do that from your raspberry pi. Mine is headless (no keyboartd/monitor) so I did that from another computer which works fine as well.

Let me know how you progress. It looks like you are close to getting your auth token. Once you have that, the rest should be 'easy'.

H

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 21 November 2020 12:17
by pietje1951
After typing in python3 example.py I get this:

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Nov 21 10:17:48 2020 from 192.168.178.133
pi@raspberrypi:~ $ cd LGAC_SmartT
pi@raspberrypi:~/LGAC_SmartT $ python3 example.py
Session expired.
d27bb3f0-7149-11d3-80af-7440bec3b009: AIRCONDITIONER (AC RAC_056905_WW)
Traceback (most recent call last):
File "example.py", line 214, in <module>
example(sys.argv[1:])
File "example.py", line 209, in example
with open(STATE_FILE, 'w') as f:
PermissionError: [Errno 13] Permission denied: 'wideq_state.json'
pi@raspberrypi:~/LGAC_SmartT $

Thank you again !

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 21 November 2020 14:15
by heggink
OK, weird. This pythion script needs to create and write a file called wideq_state.json and it's complaining that it cannot access it (permission denied).

Can you check if the file already exists (ls -l wideq_state.json) and who owns it?
If it does not exist, can you check if you have write permission to the directory you are in?
If the file does exist, probably simplest to delete it (sudo rm wideq_state.json) and retry the command (python3 example.py).

Let me know.

Herman
ps: maybe more helpful if we just resolve things over the phone. I am a bit tied for time today but could probably help until 4pm. Just pm me.

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 21 November 2020 17:05
by pietje1951
Hello,

Thank you again for your swift answer !
This is the result of my efforts until now.
It would be very fine if I could call you.
You can call me, I can give you my number.
Tomorrow afternoon and tomorrow evening I am at home.
I am not in a hurry.
Bye.


pi@raspberrypi:~ $ cd LGAC_SmartT
pi@raspberrypi:~/LGAC_SmartT $ ls -l wideq_state.json
-rw-r--r-- 1 root root 467 Nov 21 10:26 wideq_state.json
pi@raspberrypi:~/LGAC_SmartT $ sudo rm wideq_state.json
pi@raspberrypi:~/LGAC_SmartT $ python3 example.py
Log in here:
https://nl.m.lgaccount.com/login/sign_i ... e=password
Then paste the URL where the browser is redirected:
https://nl.m.lgaccount.com/login/iabClo ... geapi.com/
d27bb3f0-7149-11d3-80af-7440bec3b009: AIRCONDITIONER (AC RAC_056905_WW)
pi@raspberrypi:~/LGAC_SmartT $ nano LGACServerNew.py
pi@raspberrypi:~/LGAC_SmartT $ pi@raspberrypi:~/LGAC_SmartT $ sudo chmod +x LGACServerNew.py
pi@raspberrypi:~/LGAC_SmartT $ ./LGACServerNew.py
./LGACServerNew.py: line 1: import: command not found
./LGACServerNew.py: line 2: import: command not found
./LGACServerNew.py: line 4: syntax error near unexpected token `('
./LGACServerNew.py: line 4: `module_paths = [x[0] for x in os.walk( os.path.join(os.path.dirname(__file__), '.', '.env/lib/') ) if x[0].endswith('site-packages') ]'

Re: Python Plugin: LG Smart AC (SmartThinQ)

Posted: Saturday 21 November 2020 21:02
by jsmit
Hello,

I am making progress.
Installes the LGACSmartThing from Heggink.
After that is use wideq from Gladhorn
I can see my 4 airco's.
But when i try to start ./LGACServerNew.py i get the next message:
server: Starting server on 127.0.0.1 22233
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
File "./LGACServerNew.py", line 97, in ac_commands_handler
client = wideq.Client.from_token(token)
File "/home/pi/LGAC_SmartT/wideq.py", line 555, in from_token
client.refresh()
File "/home/pi/LGAC_SmartT/wideq.py", line 542, in refresh
self._session, self._devices = self.auth.start_session()
File "/home/pi/LGAC_SmartT/wideq.py", line 257, in start_session
return Session(self, session_id), as_list(session_info['item'])
KeyError: 'item'
2020-11-21T19:52:08Z <Greenlet at 0x753715d0: ac_commands_handler('0ffa2f76-fd2b-16c2-a237-402f86876675', '6d9a264dcdf361d2365c13e72c5ca5cdeaf5df25716ab4ce6, <Queue at 0x75340810>)> failed with KeyError

Does anyone now how to solve this?

Best regards Jacco