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

Python and python framework

Moderator: leecollings

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 14:11 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.
Yes I did, I'm using the LG Thinq app every day. But I think that could be a problem if I got the url and logged in with my LG account.
Didnt get that far yet, I get the error first thing after executing python3 example.py...

Thanks in advance for helping me.
User avatar
waltervl
Posts: 5149
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 »

Seems like an IO error, perhaps no write access?
What happens with sudo?

Code: Select all

sudo python3 example.py -c NL -l en-US
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
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 »

waltervl wrote: Wednesday 13 October 2021 17:11 Seems like an IO error, perhaps no write access?
What happens with sudo?

Code: Select all

sudo python3 example.py -c NL -l en-US
Same error.
Really don't know what's going wrong. Tried to delete and clone the installation again, no succes.
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 »

OK, sorry, that was my fault. There was a redundant "raise IOError" which is removed now. I didn't realized that I'm testing another version (which was OK actually) - sorry, I'm still learning :)

Just

Code: Select all

git pull --rebase
to update your local repository and try again.
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: Thursday 14 October 2021 10:06 OK, sorry, that was my fault. There was a redundant "raise IOError" which is removed now. I didn't realized that I'm testing another version (which was OK actually) - sorry, I'm still learning :)

Just

Code: Select all

git pull --rebase
to update your local repository and try again.
Yes!! Working! I added new hardware and I see new devices now. Going to test it, thank you very much.
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.
Hello @boosjgm.

I've checked your wideq_state.json file and I was able to read parameters. It shows that your heatpump's model operates with LG Thinq API version 1. Currently my addon doesn't support these devices, it supports API version 2 only - which is a little bit different. But, fortunately there's a domoticz plugin for v1 already (viewtopic.php?p=206548#p206548) - maybe it will work for your device.
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. I will try to install V1
BartS12
Posts: 3
Joined: Friday 13 April 2018 23:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by BartS12 »

I'm trying to get my multisplit LG AC to work via domoticz as well, but so far no luck. I'm not getting past the 'sign in' with the LG app; likely because my current LG account is a "google account".

The current sign-in page doesn't allow anymore to 'sign in with google'. And I'm hesitant to delete my google sign in account, sign up for a new one, and start over from scratch; because I *can* control my AC via my Google home App, and the LG app on my phone is also working fine. Wouldn't want to start over with that - if possible...

Is there a solution?
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 »

BartS12 wrote: Tuesday 09 November 2021 13:44 I'm trying to get my multisplit LG AC to work via domoticz as well, but so far no luck. I'm not getting past the 'sign in' with the LG app; likely because my current LG account is a "google account".

The current sign-in page doesn't allow anymore to 'sign in with google'. And I'm hesitant to delete my google sign in account, sign up for a new one, and start over from scratch; because I *can* control my AC via my Google home App, and the LG app on my phone is also working fine. Wouldn't want to start over with that - if possible...

Is there a solution?
I use an LG account and can control the AC with the Google Home app, so I think you're safe to switch to an LG account. I never used a google account with my LG airco.
v40jlt4
Posts: 20
Joined: Saturday 24 January 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Netherlands
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by v40jlt4 »

Got my LG PC18SQ today, so really keen on adding it to domoticz.

Everything went wrong, trying to get python to work so I did a fresh domoticz install. (thank goodness I've got DB backups).

I did end up with raspian lite bullsey & python 3.9.2 though after a fresh raspbian/domoticz install on my rPi3B+
domoticz = Version: 2021.1 (build 13872)

The whole logging on (amazon account), getting a device ID and creating the json file went well.
I moved the json file to the correct location and restarted domoticz.

Yes, LG think is available in "hardware" I fill out country/language/device ID. Add

I want to go to "devices"...

Everything gone, no more devices, no hardare, domoticz keeps crashing.

Only after I move the json file out of the way, domoticz is alive again.

I did go into the thinq app several times to accept everything that can be accepted, but as soon as I put the wideq_state.json file back in /home/pi/domoticz It's all over again.

I see these errors:

2021-11-13 20:22:34.285 Error: Airco Woonkamer: 'onStart' failed 'EOFError':'EOF when reading a line'.
2021-11-13 20:22:34.285 Error: Airco Woonkamer: Exception traceback:
2021-11-13 20:22:34.285 Error: Airco Woonkamer: ----> Line 394 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/plugin.py'
2021-11-13 20:22:34.285 Error: Airco Woonkamer: ----> Line 80 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/plugin.py'
2021-11-13 20:22:34.285 Error: Airco Woonkamer: ----> Line 269 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/example.py'
2021-11-13 20:22:34.285 Error: Airco Woonkamer: ----> Line 25 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/example.py'

I did not find a solution in this thread. So any help would be greatly appreciated.
Last edited by v40jlt4 on Sunday 14 November 2021 11:12, edited 2 times in total.
v40jlt4
Posts: 20
Joined: Saturday 24 January 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Netherlands
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by v40jlt4 »

Strange thing. If I use it outside Domoticz , it works fine

python3 example.py -c NL -l en-US ac-config <MY_DEVICE_ID>
supported_operations: [<ACOp.OFF: '@AC_MAIN_OPERATION_OFF_W'>, <ACOp.ON: '@AC_MAIN_OPERATION_ON_W'>, <ACOp.RIGHT_ON: '@AC_MAIN_OPERATION_RIGHT_ON_W'>, <ACOp.LEFT_ON: '@AC_MAIN_OPERATION_LEFT_ON_W'>, <ACOp.ALL_ON: '@AC_MAIN_OPERATION_ALL_ON_W'>]
supported_on_operation: ACOp.ALL_ON
get_filter_state: 0
get_mfilter_state: 0
get_energy_target: 757
get_power: (757, 'watts')
get_outdoor_power: (757, 'watts')
get_volume: 0
get_light: 0
get_zones: []


python3 example.py -c NL -l en-US mon <MY_DEVICE_ID>
state on; HEAT; cur 76°F; cfg 72°F; fan speed LOW
state on; HEAT; cur 76°F; cfg 72°F; fan speed LOW
state on; HEAT; cur 76°F; cfg 72°F; fan speed LOW
state on; HEAT; cur 76°F; cfg 72°F; fan speed LOW
state on; HEAT; cur 76°F; cfg 72°F; fan speed LOW


Python 3.9.2 & domoticz issue perhaps?
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 »

I think there is a problem with the new raspbian bullsey, and with Python 3.9.2 which is in it

viewtopic.php?f=6&t=37376

plugins that require python don't work - domoticz will then shut down
v40jlt4
Posts: 20
Joined: Saturday 24 January 2015 13:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Netherlands
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by v40jlt4 »

johnny86 wrote: Sunday 14 November 2021 12:40 I think there is a problem with the new raspbian bullsey, and with Python 3.9.2 which is in it
Ah, thanks, that has to be it. What a pity.
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 »

since this evening I get errors in the domoticz log. Maybe it's an outage at LG, or something else?

Code: Select all

2021-11-17 22:41:49.557 Error: ConbeeDeconz hardware (12) thread seems to have ended unexpectedly
2021-11-17 22:42:01.111 Error: LG Thinq: (LG Thinq) 'onStart' failed 'TokenError'.
2021-11-17 22:42:01.111 Error: LG Thinq: (LG Thinq) ----> Line 390 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/plugin.py', function onStart
2021-11-17 22:42:01.111 Error: LG Thinq: (LG Thinq) ----> Line 118 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/plugin.py', function onStart
2021-11-17 22:42:01.111 Error: LG Thinq: (LG Thinq) ----> Line 267 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/example.py', function example
2021-11-17 22:42:01.111 Error: LG Thinq: (LG Thinq) ----> Line 224 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/wideq/client.py', function refresh
2021-11-17 22:42:01.111 Error: LG Thinq: (LG Thinq) ----> Line 461 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/wideq/core.py', function refresh
2021-11-17 22:42:01.111 Error: LG Thinq: (LG Thinq) ----> Line 376 in '/home/pi/domoticz/plugins/domoticz_lg_thinq_plugin/wideq/core.py', function oauth_request
2021-11-17 22:42:01.213 Error: LG Thinq: (LG Thinq) wideq_state.json status file missing or corrupted. Heartbeat has nothing to do.
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.

I've had also some errors in my logs today:

Code: Select all

2021-11-18 02:42:34.112 Error: LG ThinQ: (LG ThinQ) 'onHeartbeat' failed 'ConnectionError'.
But now it's back online:

Code: Select all

2021-11-18 03:01:28.477 LG ThinQ: (LG ThinQ) Session expired, refreshing...
So maybe you are right, maybe there was some LG outage. Is it working for you now?
My timezone is UTC+1
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: Thursday 18 November 2021 8:35 Hi @gvrgvr.

I've had also some errors in my logs today:

Code: Select all

2021-11-18 02:42:34.112 Error: LG ThinQ: (LG ThinQ) 'onHeartbeat' failed 'ConnectionError'.
But now it's back online:

Code: Select all

2021-11-18 03:01:28.477 LG ThinQ: (LG ThinQ) Session expired, refreshing...
So maybe you are right, maybe there was some LG outage. Is it working for you now?
My timezone is UTC+1
Ah yes, working again, so it was an LG outage. Same timezone btw.
Thanks.
marson
Posts: 1
Joined: Saturday 27 November 2021 22:44
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by marson »

Hello

I too have a problem to past the creation of wideq_state.json when installing the plugin

As some people in this threat I am getting the following error:

Code: Select all

domoticz@domoticz:~/LGAC_SmartT$ python3 example.py
Log in here:
https://pl.m.lgaccount.com/login/sign_in?country=PL&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://pl.m.lgaccount.com/login/iabClose?access_token=55a28d8f96aabdc2f22fe6bbc2fa8ba32419df9bfdb4a456717e71292eb1df2f65dccfa1a51f471a37484b636c48cfda&refresh_token=9af0e8ea0e0665058fd766b07a5c021a7237abead3d2c8a1ac2aa202417e0bb3686ddca663b6b5abaf93815c37c40bc6&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/domoticz/LGAC_SmartT/wideq.py", line 474, in devices
    self._devices = self.session.get_devices()
  File "/home/domoticz/LGAC_SmartT/wideq.py", line 465, in session
    self._session, self._devices = self.auth.start_session()
  File "/home/domoticz/LGAC_SmartT/wideq.py", line 257, in start_session
    return Session(self, session_id), as_list(session_info['item'])
KeyError: 'item'

EDIT:

I solved the problem, at the begining I was trying to use Olinek's plugin, that was linked at the beginning of the topic, then I found the fork from @heggink but with the same error as before and finally on next pages I found the other plugin from @majki available at https://github.com/majki09/domoticz_lg_thinq_plugin and this plugin works for me without any problems, so thank you @majki for the good work. I have 2 questions for you

1. I have a multi-split installation in 2 rooms, how can I add second AC? Will it be enough to add second ID on hardware tab or do I need to change something in the code?

2. Will you be able to add more functionality to the plugin like enabling air jonization, jet mode function or air quality meter? All those options are available at LG ThinQ app and on the remote control so it would be nice to get it also on the plugin.

Also I would like to thank you for your great work :)
superprzemo
Posts: 4
Joined: Tuesday 22 February 2022 23:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Warsaw
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by superprzemo »

majki wrote: Thursday 14 October 2021 10:59
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.
Hello @boosjgm.

I've checked your wideq_state.json file and I was able to read parameters. It shows that your heatpump's model operates with LG Thinq API version 1. Currently my addon doesn't support these devices, it supports API version 2 only - which is a little bit different. But, fortunately there's a domoticz plugin for v1 already (viewtopic.php?p=206548#p206548) - maybe it will work for your device.
Hello @majki

I try install your plugin, I get information after start example.py:

thinq2 devices: 1
c0386fd2-f2b4-1aae-892f-dc0398XXXXX: Pompa ciepła (AC AWHP_019101_WW / thinq2)
I moved file wideq_state.json to domoticz folder, restart domoticz and add hardware LG ThinQ on domoticz menu.
Domoticz add new devices, but these devices are not working (the devices are gray and do not show values) and get also errors in domoticz log (please see on attached picture).
IMG_20220222_221003.jpg
IMG_20220222_221003.jpg (358.34 KiB) Viewed 2987 times
I think that this plugin does not handle heat pumps properly :(

How to try to add heat pump support?

I can send wideq_state file content on PM.
superprzemo
Posts: 4
Joined: Tuesday 22 February 2022 23:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Warsaw
Contact:

Re: Python Plugin: LG Smart AC (SmartThinQ)

Post by superprzemo »

Hi @majki,

I can not send you my wideq_status.json to your PM, because I am blocked from sending PM :(
I got PM from you, but I can not reply to it.
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 »

superprzemo wrote: Thursday 24 February 2022 12:50 Hi @majki,

I can not send you my wideq_status.json to your PM, because I am blocked from sending PM :(
I got PM from you, but I can not reply to it.
Maybe because your account is fresh new, we had this issue before:
viewtopic.php?p=280432#p280432
Maybe you need to write more posts to write PMs.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest