Code Monkey home page Code Monkey logo

Comments (13)

dacrypt avatar dacrypt commented on August 14, 2024 3

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:

  1. 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
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"
    }
}
  1. Getting energy usage from 2 days ago (total of 6.6 kWh) and a graph showing usage from 00:00am to 8:00am.

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"
    }
}
  1. Request report for the WEEK (2020.01.13 - 2020.01.19) with a total of 56.4 kWh and 3days 20hours usage

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"
    }
}
  1. MONTH usage (2020.01) with a total of 171.2 kWh and 10 days, 16 hours and 14minutes usage:

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:
IMG_CDB0642AD214-1

from wideq.

sampsyo avatar sampsyo commented on August 14, 2024

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?

from wideq.

xman123 avatar xman123 commented on August 14, 2024

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....

from wideq.

sampsyo avatar sampsyo commented on August 14, 2024

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?

from wideq.

xman123 avatar xman123 commented on August 14, 2024

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...

  • CirculateDir: 0
    Traceback (most recent call last):
    File "example.py", line 230, in
    main()
    File "example.py", line 226, in main
    example(args.country, args.language, args.cmd, args.args)
    File "example.py", line 186, in example
    example_command(client, cmd, args)
    File "example.py", line 162, in example_command
    func(client, *args)
    File "example.py", line 55, in mon
    if isinstance(desc, wideq.EnumValue):
    UnboundLocalError: local variable 'desc' referenced before assignment

from wideq.

dacrypt avatar dacrypt commented on August 14, 2024

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"
          },

from wideq.

xman123 avatar xman123 commented on August 14, 2024

How to add this to wideq code and how to test it?

from wideq.

sampsyo avatar sampsyo commented on August 14, 2024

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.

from wideq.

xman123 avatar xman123 commented on August 14, 2024

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???

from wideq.

sampsyo avatar sampsyo commented on August 14, 2024

Something like that? It's worth a shot, I guess? Just a guess, really…

from wideq.

dacrypt avatar dacrypt commented on August 14, 2024

I've tested and these are the results:

Powered off:
{'InOutInstantPower': '50'}{'OutTotalInstantPower': '0'}

Powered on (execute several times to see if it changes...):

  1. {'InOutInstantPower': '1213'} {'OutTotalInstantPower': '0'}
  2. {'InOutInstantPower': '1213'} {'OutTotalInstantPower': '0'}
  3. {'InOutInstantPower': '1230'} {'OutTotalInstantPower': '0'}

Switch to power saving mode:
{'InOutInstantPower': '1202'}{'OutTotalInstantPower': '0'}

from wideq.

xman123 avatar xman123 commented on August 14, 2024

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...

from wideq.

AlexandreLogist avatar AlexandreLogist commented on August 14, 2024

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:

  1. 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

from wideq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.