ollo69 / ha-smartthinq-sensors

HomeAssistant custom integration for SmartThinQ LG devices configurable with Lovelace User Interface.
Apache License 2.0
1.17k stars 160 forks source link

Washer and dryer energy monitoring API docs #814

Open Daniel15 opened 1 month ago

Daniel15 commented 1 month ago

This issue complements #748 and provides details about the API calls used to retrieve energy monitoring data from LG washers and dryers, to assist integrating the data into this project. Discussions aren't enabled in this repo so I thought an issue is a good enough place to put this info. I can try to implement this some time in the next few weeks, but I'm not familiar with Python so I'll have to learn how to use it for this :)

Washer I've got a WM6700HBA washing machine. For the energy usage, it makes a HTTP request to:

https ://aic-service.lgthinq.com:46030/v1/service/laundry/xxxxxxxxxxxxxxxx/energy-history?
  type=period
  &period=hour
  &startDate=2024-10-11
  &endDate=2024-10-11
  &washerType=M
  &twinYn=N

This appears to be similar to other URLs used to load other data, so I'd guess this repo already has code to determine the right base URL.

xxxxxxxxxxxxxxxx is probably some sort of GUID for the washer. I've redacted it in case it's a personal identifier.

Request headers (some data redacted):

Accept: application/json
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/json;charset=UTF-8
Cookie: dtCookie=xxxxxxx|xxxxxxx
Host: aic-service.lgthinq.com:46030
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
x-api-key: xxxxxxxxx
x-app-version: LG ThinQ/5.0.30250
x-client-id: xxxxxxxxxx
x-country-code: US
x-emp-token: xxxxxxxxxx
x-language-code: en-US
x-message-id: xxxxxxxxx
x-origin: app-web-ANDROID
X-Requested-With: com.lgeha.nuts
x-service-code: SVC202
x-service-phase: OP
x-thinq-app-level: PRD
x-thinq-app-logintype: LGE
x-thinq-app-os: ANDROID
x-thinq-app-pageid: GWM_ENM01_Main/201
x-thinq-app-type: NUTS
x-thinq-app-ver: 5.0.3000
x-user-no: xxxxxxxxxxxx

Response:

{
  "resultCode": "0000",
  "result": {
    "count": 0,
    "power": 0,
    "energyWater": 0,
    "energyDetergent": 0,
    "energySoftener": 0,
    "powerWh": 0,
    "periodicEnergyData": 0,
    "item": [
      {
        "usedDate": "2024-10-11 00:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 01:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 02:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 03:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 04:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 05:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 06:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 07:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 08:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 20
      },
      {
        "usedDate": "2024-10-11 09:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 89
      },
      {
        "usedDate": "2024-10-11 10:00:00",
        "count": 1,
        "power": 232,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 383
      },
      {
        "usedDate": "2024-10-11 11:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 122
      },
      {
        "usedDate": "2024-10-11 12:00:00",
        "count": 1,
        "power": 263,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 139
      },
      {
        "usedDate": "2024-10-11 13:00:00",
        "count": 1,
        "power": 200,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 177
      },
      {
        "usedDate": "2024-10-11 14:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 210
      },
      {
        "usedDate": "2024-10-11 15:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 77
      },
      {
        "usedDate": "2024-10-11 16:00:00",
        "count": 1,
        "power": 186,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 297
      },
      {
        "usedDate": "2024-10-11 17:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 7
      },
      {
        "usedDate": "2024-10-11 18:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 19:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 20:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 21:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 22:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-11 23:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      },
      {
        "usedDate": "2024-10-12 00:00:00",
        "count": 0,
        "power": 0,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 0
      }
    ]
  }
}

The periodicEnergyData field matches up with what's shown in the app:

image

      {
        "usedDate": "2024-10-11 10:00:00",
        "count": 1,
        "power": 232,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 383
      },

The power field also has a value, but I'm not sure what it means. energyDetergent, energySoftener, energyWater, and powerWh are always 0 on my model. count is the number of times the washing machine was used in that time period - more useful for the larger (weekly, monthly, yearly) rollups:

      {
        "usedDate": "2024-09",
        "count": 31,
        "power": 6266,
        "energyWater": 0,
        "energyDetergent": 0,
        "energySoftener": 0,
        "powerWh": 0,
        "periodicEnergyData": 10131
      },

Dryer I've got a DLEX6700B dryer. The API URL and response format are identical to the washer.

The ThinQ app also attempts to open an MQTT connections. I'm not sure what it uses it for, though.

mrfixitpa commented 4 weeks ago

I just came here looking for this feature. I wish I knew how to do any of that stuff but unfortunately I have to wait for the masters. Im really looking to have this linked up to HA Energy monitoring.

dhruvb14 commented 3 weeks ago

Also looking for energy integration if possible!