Open xman123 opened 4 years ago
IIRC, I found some status information like this associated with my model of AC unit, but it was always reporting zero energy. In general, it seems to me like the only things that actually work in the API are values that are visible in the LG app, and I don’t recall seeing power usage in the app—do you see it?
I have LG PC18SQ and I have current power consumption info in lg app and daily/weekly/monthly power usage info but in new version of LG app they don`t show real time value for power consumption and I hope that I can get it on some way with wideq....
Oh cool. I don't think my device supports it, but can you maybe try example.py mon
on yours to see if there's more data in there than I have?
All what I can get with ac-mon is: on; HEAT; cur 66°F; cfg 60°F; fan speed NATURE
With just "mon": Polling... Polling... Polling...
I also have power usage reports in the app. Unfortunately I haven't been able to use mon
either.
The following might be useful to find out how to obtain the data:
In the app, you can set a desired maximum energy consumption in a month. It will be used to graph a line in the usage graph so you can see it. It's also possible to see current, daily, weekly and monthly usage in kWh
"GetEnergyDesiredValue": {
"_comment": "GET_에너지 목표량",
"cmd": "Control",
"cmdOpt": "Get",
"value": "EnergyDesiredValue"
},
"SetEnergyDesiredValue": {
"_comment": "SET_목표에너지",
"cmd": "Control",
"cmdOpt": "Set",
"value": "{\"Schedule\" : \" { \"Day\":\"{EnergyDesiredValueDay}\",\"Week\":\"{EnergyDesiredValueWeek}\",\"Month\":\"{EnergyDesiredValueMonth}\" } \" } ",
"encode": true
},
"GetOutTotalInstantPower": {
"_comment": "GET_실외기 총순시전력",
"cmd": "Config",
"cmdOpt": "Get",
"value": "OutTotalInstantPower"
},
"GetInOutInstantPower": {
"_comment": "GET_실내외기 총순시전력",
"cmd": "Config",
"cmdOpt": "Get",
"value": "InOutInstantPower"
},
How to add this to wideq code and how to test it?
Oh cool! You could try doing ac._get_config('OutTotalInstantPower')
or the same for the other string, InOutInstantPower
. (You could drop this into the ac_config
function in example.py
just to try it out.) It doesn't work for my unit, but maybe it does for yours.
It must look like this?
def ac_config(client, device_id): ac = wideq.ACDevice(client, _force_device(client, device_id)) print(ac.get_filter_state()) print(ac.get_mfilter_state()) print(ac.get_energy_target()) print(ac.get_volume()) print(ac.get_light()) print(ac.get_zones()) print(ac._get_config('InOutInstantPower'))
Just last line and it need to work???
Something like that? It's worth a shot, I guess? Just a guess, really…
I've tested and these are the results:
Powered off:
{'InOutInstantPower': '50'}{'OutTotalInstantPower': '0'}
Powered on (execute several times to see if it changes...):
{'InOutInstantPower': '1213'} {'OutTotalInstantPower': '0'}
{'InOutInstantPower': '1213'} {'OutTotalInstantPower': '0'}
{'InOutInstantPower': '1230'} {'OutTotalInstantPower': '0'}
Switch to power saving mode:
{'InOutInstantPower': '1202'}{'OutTotalInstantPower': '0'}
Furthermore, the app does provide nice graphs with day, week and month usage that you navigate. In order to get this functionality I checked some older pull requests made by other but couldn't make it work.
Since I think this is a must feature to have (specially for home assistant), I've installed mitmproxy and this is what I see from my investigations:
Request:
https://aic.lgthinq.com:46030/api/aircon/inquiryPowerData
2020-01-22 01:56:12 POST HTTP/1.1 ← 200 application/json 92b 244ms
Request Response Detail
Host: aic.lgthinq.com:46030
x-host: aic.lgthinq.com
Cookie: dtCookie=25650545404591_70|U21hcnRUaGluc
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
Accept-Encoding: gzip, deflate, br
x-thinq-app-ver: 3.0.1702
x-thinq-app-type: NUTS
x-dtreferer: file:///var/mobile/Containers/Data/Application/A5C8F1B0-7F00-44AF-820F-AB069CC9A587/Library/Application%20Support/www/index.html#/GAM_ENM01_Moment/003/d27c7740-7149-11d3-80b4-7440be
deeb8
x-language-code: pt-BR
Origin: file://
x-client-id: 5ba47f1ca86d3c4f11ce51d0ae8be03650a0f5d588e993738ff442131682
x-dtpc: 476110426_669h9
x-thinq-app-level: PRD
Content-Length: 115
Connection: keep-alive
x-user-no: BR191203763215
x-service-code: SVC202
Accept-Language: es-es
x-message-id: j1I5MGUiGAyT7MX4YMha.
x-emp-token: cdb412ce8645e3d737a04997081b9d9a23f6478a9bde4e5df2d34cafa05ec11a2c498c451d5400b854ef3a998619
Accept: application/json
Content-Type: application/json;charset=UTF-8
x-api-key: VGhpblEyLjAgU0VSVklDRQ==
x-thinq-app-os: IOS
x-country-code: BR
x-service-phase: OP
JSON [m:auto]
{
"lgedmRoot": {
"deviceId": "d27c7740-7149-11d3-80b4-7440be9dee",
"period": "Hour_20200122T000000Z/20200123T000000Z"
}
}
Response:
Date: Wed, 22 Jan 2020 06:56:12 GMT
Server: Apache
X-Powered-By:
Content-Length: 92
Set-Cookie: dtCookie=2565054048591_70|U21hcnRUaGlu; Path=/; Domain=.lgthinq.com
Connection: close
Content-Type: application/json;charset=utf-8
JSON [m:auto]
{
"lgedmRoot": {
"powerData": "00_0_3/01_0_918/02_75_263",
"returnCd": "0000",
"returnMsg": "OK"
}
}
Request
https://aic.lgthinq.com:46030/api/aircon/inquiryPowerData
{
"lgedmRoot": {
"deviceId": "d27c7740-7149-11d3-80b4-7440be9dee",
"period": "Hour_20200120T000000Z/20200121T000000Z"
}
}
Response
{
"lgedmRoot": {
"powerData": "08_0_649/09_0_813/10_0_1165/11_0_1184/12_0_1163/13_0_1148/14_0_295/00_360_159",
"returnCd": "0000",
"returnMsg": "OK"
}
}
Request
https://aic.lgthinq.com:46030/api/aircon/inquiryPowerData
{
"lgedmRoot": {
"deviceId": "d27c7740-7149-11d3-80b4-7440be9deeb8",
"period": "Day_20200113T000000Z/20200119T000000Z"
}
}
Response
{
"lgedmRoot": {
"powerData": "13_1320_17934/14_1185_10019/15_735_5294/16_1080_9269/17_390_1726/18_240_3095/19_570_9084",
"returnCd": "0000",
"returnMsg": "OK"
}
}
Request
https://aic.lgthinq.com:46030/api/aircon/inquiryPowerData
{
"lgedmRoot": {
"deviceId": "d27c7740-7149-11d3-80b4-7440be9deeb8",
"period": "Day_20200101T000000Z/20200131T000000Z"
}
}
Response:
{
"lgedmRoot": {
"powerData": "01_1124_13750/02_930_8830/03_825_6180/04_840_8199/05_960_10412/06_870_8935/07_557_3017/08_643_5824/09_528_3610/10_342_5825/11_1065_28551/12_690_3941/13_1320_17934/14_1185_10019/15_73
5_5294/16_1080_9269/17_390_1726/18_240_3095/19_570_9084/20_345_6417/21_60_176/22_75_1184",
"returnCd": "0000",
"returnMsg": "OK"
}
}
Example graph:
This working for me when I call "ac-config", for InOutInstantPower I have some value, look like current power usage in Watts but for OutTotalInstantPower I have 0....thank you...
Furthermore, the app does provide nice graphs with day, week and month usage that you navigate. In order to get this functionality I checked some older pull requests made by other but couldn't make it work.
Since I think this is a must feature to have (specially for home assistant), I've installed mitmproxy and this is what I see from my investigations:
- Energy monitoring current day form the app:
Request:
https://aic.lgthinq.com:46030/api/aircon/inquiryPowerData 2020-01-22 01:56:12 POST HTTP/1.1 ← 200 application/json 92b 244ms Request Response Detail ....
Hi,
How did you guys manage to get the call ? Tried both in Wireshark & Fiddler but it seems the app can't connect (or won't) to the internet from a mobile device, where the mobile browser is fine. Some integrated security ?
I would like to implement the call to have daily / weekly energy consumption stats in Home Assistant.
Kind regards, Alexandre
Hi, can I on some way check current power usage of my AC with wideq?
Thanks.