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

Python and python framework

Moderator: leecollings

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 »

Alright then.

You can get this plugin from my github repo:
https://github.com/majki09/domoticz_lg_thinq_plugin

heggink wrote: Monday 19 July 2021 16:07 Excellent news. Is this compatible with the v1 logins as well? What is your GitHub repo? Love to see it.
Great work. Many thanks.
Since works are on the way with https://github.com/sampsyo/wideq to integrate both v1 and v2 API versions, I decided to experiment with my new LG AC and this plugin currently works with LG ThinQ (API v2) devices only. If you want to use v1 device, there is plugin already prepared by olinek2 (https://github.com/olinek2/LGAC_SmartT)

Please try it out and let me know what you think, because it's my first domoticz plugin ;)
User avatar
waltervl
Posts: 5148
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: Tuesday 20 July 2021 14:16 Alright then.

You can get this plugin from my github repo:
https://github.com/majki09/domoticz_lg_thinq_plugin
Thank you, I have added it to the Wiki plugins page https://www.domoticz.com/wiki/Plugins
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jsmit
Posts: 28
Joined: Wednesday 02 November 2016 19:02
Target OS: Raspberry Pi / ODroid
Domoticz version: v2020.2
Location: Nearby Hoorn NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by jsmit »

Majki,

Thanks for the plugin.
It works great.
I have a new single split and multi split air conditioner.
All the units are working.
Keep up the good work.

Jacco
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 »

jsmit wrote: Friday 27 August 2021 10:23 Majki,

Thanks for the plugin.
It works great.
I have a new single split and multi split air conditioner.
All the units are working.
Keep up the good work.

Jacco
Hi Jacco,

great to hear that!
Thanks for a review ;)
boosjgm
Posts: 4
Joined: Saturday 25 September 2021 21:44
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by boosjgm »

I have a LG heatpump (HM091M.U43).

I have successfully followed all instructions for the V2 api.

I have created the wideq_state.json and "python example.py ls" also gives the correct device:
d27fab90-7149-11d3-80c9-xxxxxx: Heat pump air to water (AC AWHP_019101_WW/thinq1).

In domoticz the AC devices are also created (although more for an air conditioner than for a heat pump).

However in the domoticz log I see:
2021-09-25 21:53:44.085 Error: LG Thinq Heat Pump: (LG Thinq Heat Pump) wideq_state.json status file missing or corrupted. Heartbeat has nothing to do.

What is missing or does the heat pump need an additional coding?
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 »

boosjgm wrote: Saturday 25 September 2021 21:58 I have a LG heatpump (HM091M.U43).

I have successfully followed all instructions for the V2 api.

I have created the wideq_state.json and "python example.py ls" also gives the correct device:
d27fab90-7149-11d3-80c9-xxxxxx: Heat pump air to water (AC AWHP_019101_WW/thinq1).

In domoticz the AC devices are also created (although more for an air conditioner than for a heat pump).

However in the domoticz log I see:
2021-09-25 21:53:44.085 Error: LG Thinq Heat Pump: (LG Thinq Heat Pump) wideq_state.json status file missing or corrupted. Heartbeat has nothing to do.

What is missing or does the heat pump need an additional coding?
Hi boosjgm!
Currently I only have an AC with V2 API so I was able to write and test a plugin for ACs. Unfortunately I don't own a LG heat pump and yes, the plugin needs a code for those. Maybe someone who is able to will write it. Or you can if you know how to code in Python.
boosjgm
Posts: 4
Joined: Saturday 25 September 2021 21:44
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by boosjgm »

Thanks for your answer.

My knowlege of python is limited, but i can try with some help.

If I look in the thinq-app (android) then the information is very limited and depending of settings in the controler of the LG itself. Currently I use in the controler LG only "water (outlet)". Then you see in Thinq:
- 0n/Off
- water temp target -- you can set target water temp
- water temp current
- heating / AI -- AI is automatic setting water temp target. You can influence this by -x to +x degrees

If the setting in the controler is "water and room temp" then you can influence in Thinq the room temp:
- 0n/Off
- room temp target -- you can set target room temp
- room temp current
- heating / AI -- AI is automatic setting room temp target. You can influence this by -x to +x degrees
Note: what heating / AI does in this setting is not very clear. There is in this setting no distinction between the influence of water temp and room temp

Futhermore there are boundaries of the target settings. You can set them in the controler of the LG itself. For example you can set water temp target 27 - 35 or room temp target 18 - 21. I presume the thinq app can read those boundaries.
jsmit
Posts: 28
Joined: Wednesday 02 November 2016 19:02
Target OS: Raspberry Pi / ODroid
Domoticz version: v2020.2
Location: Nearby Hoorn NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by jsmit »

Majki,

After a reboot suddenly the plugin is not working anymore.
I get:
2021-09-30 18:52:03.090 Error: Airco-Jacco: (Airco-Jacco) 'onHeartbeat' failed 'AttributeError'.
2021-09-30 18:52:03.090 Error: Airco-Jacco: (Airco-Jacco) ----> Line 407 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/plugin.py', function onHeartbeat
2021-09-30 18:52:03.090 Error: Airco-Jacco: (Airco-Jacco) ----> Line 258 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/plugin.py', function onHeartbeat
I have tried to re-install the plugin
But then i get the next error trying to use the wideq
Traceback (most recent call last):
File "example.py", line 335, in <module>
main()
File "example.py", line 331, in main
example(args.country, args.language, args.verbose, args.cmd, args.args)
File "example.py", line 259, in example
example_command(client, cmd, args)
File "example.py", line 226, in example_command
func(client, *args)
File "example.py", line 34, in ls
for device in client.devices:
File "/home/pi/domoticz/plugins/wideq/wideq/client.py", line 135, in devices
self._devices = self.session.get_devices()
File "/home/pi/domoticz/plugins/wideq/wideq/core.py", line 526, in get_devices
return get_list(self.get("service/application/dashboard"), "item")
File "/home/pi/domoticz/plugins/wideq/wideq/core.py", line 517, in get
language=self.auth.gateway.language,
File "/home/pi/domoticz/plugins/wideq/wideq/core.py", line 282, in thinq_request
raise API_ERRORS

Code: Select all

(code)
TypeError: __init__() takes 1 positional argument but 2 were given
So no file is made

Can you help me with this?

Jacco
jsmit
Posts: 28
Joined: Wednesday 02 November 2016 19:02
Target OS: Raspberry Pi / ODroid
Domoticz version: v2020.2
Location: Nearby Hoorn NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by jsmit »

Starting new.

pi@raspberrypi:~/domoticz/plugins/domoticz_lg_thinq_plugin $ python3 example.py -c NL -l en-EN
Traceback (most recent call last):
File "example.py", line 235, in example
with open(STATE_FILE) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'wideq_state.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "example.py", line 343, in <module>
main()
File "example.py", line 339, in main
ret = example(args.country, args.language, args.verbose, cmd=args.cmd, args=args.args)
File "example.py", line 241, in example
raise IOError
OSError

and when i copy an old wideq_state.json is says:
Session expired.
Traceback (most recent call last):
File "example.py", line 343, in <module>
main()
File "example.py", line 339, in main
ret = example(args.country, args.language, args.verbose, cmd=args.cmd, args=args.args)
File "example.py", line 262, in example
resp = example_command(client, cmd, args)
File "example.py", line 225, in example_command
return func(client, *args)
File "example.py", line 32, in ls
for device in client.devices:
File "/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/wideq/client.py", line 135, in devices
self._devices = self.session.get_devices()
File "/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/wideq/core.py", line 526, in get_devices
return get_list(self.get("service/application/dashboard"), "item")
File "/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/wideq/core.py", line 517, in get
language=self.auth.gateway.language,
File "/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/wideq/core.py", line 282, in thinq_request
raise API_ERRORS

Code: Select all

(code)
TypeError: __init__() takes 1 positional argument but 2 were given

Jacco
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 jsmit!

Just open an LG app in your smartphone and accept their new terms.
Otherwise the script will get "0110": InvalidCredentialError and will not connect to API.

I have also had this problem, debugging the code for so long and found that all is about LG's new terms. Probably you have also received an e-mail from them. Luckily the API v2 stays the same and we still are able to use it in our domoticzes! :)

In case you still have some problems please try fresh install - with new tokens and wideq_state.json file.
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 »

boosjgm wrote: Monday 27 September 2021 9:32 Thanks for your answer.

My knowlege of python is limited, but i can try with some help.

If I look in the thinq-app (android) then the information is very limited and depending of settings in the controler of the LG itself. Currently I use in the controler LG only "water (outlet)". Then you see in Thinq:
- 0n/Off
- water temp target -- you can set target water temp
- water temp current
- heating / AI -- AI is automatic setting water temp target. You can influence this by -x to +x degrees

If the setting in the controler is "water and room temp" then you can influence in Thinq the room temp:
- 0n/Off
- room temp target -- you can set target room temp
- room temp current
- heating / AI -- AI is automatic setting room temp target. You can influence this by -x to +x degrees
Note: what heating / AI does in this setting is not very clear. There is in this setting no distinction between the influence of water temp and room temp

Futhermore there are boundaries of the target settings. You can set them in the controler of the LG itself. For example you can set water temp target 27 - 35 or room temp target 18 - 21. I presume the thinq app can read those boundaries.
Hi boosjgm!

Since I don't have a LG's heat pump in my house is very hard for me to develop this feature.
However, you can send me your wideq_state.json file with Private Message, I can try to write heat pump feature based on your device.
Recently I have my kids sick, so I have less time for hobbies :(
jsmit
Posts: 28
Joined: Wednesday 02 November 2016 19:02
Target OS: Raspberry Pi / ODroid
Domoticz version: v2020.2
Location: Nearby Hoorn NL
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by jsmit »

Majki,

Thanks for your quick response.
I have installed your latest version.
Still have some errors using example.py
~/domoticz/plugins/domoticz_lg_thinq_plugin $ python3 example.py -c NL -l en-EN
Traceback (most recent call last):
File "example.py", line 235, in example
with open(STATE_FILE) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'wideq_state.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "example.py", line 343, in <module>
main()
File "example.py", line 339, in main
ret = example(args.country, args.language, args.verbose, cmd=args.cmd, args=args.args)
File "example.py", line 241, in example
raise IOError
OSError

But i was able to get the file wideq_state.json from a backup.
Now the airco's are working again.


Jacco
boosjgm
Posts: 4
Joined: Saturday 25 September 2021 21:44
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by boosjgm »

Hi Majki

I have not sufficient rights to send you an PM
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 »

boosjgm wrote: Saturday 02 October 2021 12:59 Hi Majki

I have not sufficient rights to send you an PM
I've just sent you a PM, please try to reply.
Maybe you have not enough posts to write PMs?

majki
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 »

Hi @majki. Happy to read there's work done to support the v2 api, so I'm trying to start over.

But, I get the error

Traceback (most recent call last):
File "example.py", line 235, in example
with open(STATE_FILE) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'wideq_state.json'

Where do I get the wideq_state.json file?
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 @gvrgvr!

Just follow instructions here https://github.com/majki09/domoticz_lg_ ... stallation
You need to generate and copy wideq_state.json file to your domoticz folder, if your'e on Raspberry Pi it's probably /home/pi/domoticz.

I will change this manual copying to some automation when I will have some more free time.
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 »

majki wrote: Wednesday 13 October 2021 12:01 Hi @gvrgvr!

Just follow instructions here https://github.com/majki09/domoticz_lg_ ... stallation
You need to generate and copy wideq_state.json file to your domoticz folder, if your'e on Raspberry Pi it's probably /home/pi/domoticz.

I will change this manual copying to some automation when I will have some more free time.
Thanks for your help! But I don't understand. the generation of wideq_state.json is done by the following command right?

Code: Select all

python3 example.py -c NL -l en-EN
When I execute that I get an error so no wideq_state.json file is generated.
Traceback (most recent call last):
File "example.py", line 235, in example
with open(STATE_FILE) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'wideq_state.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "example.py", line 343, in <module>
main()
File "example.py", line 339, in main
ret = example(args.country, args.language, args.verbose, cmd=args.cmd, args=args.args)
File "example.py", line 241, in example
raise IOError
OSError
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 »

I can't check right now by myself, but please try this command:

Code: Select all

python3 example.py -c NL -l en-US
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 »

majki wrote: Wednesday 13 October 2021 13:42 I can't check right now by myself, but please try this command:

Code: Select all

python3 example.py -c NL -l en-US
I get the same error.
I asume that the file should be created by running example.py, because it's not a part of your sources, right?
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 »

That's right. Each LG user will have individual wideq_state.json file.

Just asking: have you already logged in on your smartphone's app and accepted LG's new terms?

Hopefully I will be able to look at this later today.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest