Contribution - LG ThinQ Binding

If I understand correctly your approach, there is need to provide cap.json files for each model you want to support. Please take a look on how it is implemented in Thinq-MQTT-Proxy, were there are no such files.

Hi @nemer, Thanks for your efforts! a ThinQ binding is awesome!
I followed your instructios but could’nt get the gateway to log in. I tried all different combinations. Once i changed my language to NL via the thing-Code the gateway logged in and went online. Maybe thats an option you can include?

Here’s the code:

UID: lgthinq:bridge:af26aa09a9

label: LGThinq GatewayBridge
thingTypeUID: lgthinq:bridge
configuration:
  country: NL
  password: ************
  language: nl-NL
  username: ****************

Also i have severall AC’s ,a washer and Dryer and all turned up and gave appropiate channels. The Dryer however only has a power channel. Is there anything i can do or supply in order to get this dryer to work?

EDIT: I see that i have (almost) the same dryer as mentioned above (mine’s a: RC90V9_WW) . Ill wait if those channels work for my dryer first.

Thanks, Hans ! I will fix it.

Hi Michal. I’ve already analysed (almost all) open sources that handle partially the integration with LG API. They are help me a lot and I’m very happy to count with theirs great work. However, I’m doing an effort to produce a nearly to professional work to improve the OpenHab LG user’s experience. Thus, even they having these great works done, I’m reviewing all the things, step by step, to see if we are going to the correct way. Thinq-MQTT-Proxy is a great project, and of couse, is one of the projects that I always consult to grab some information, but, this work was done based on a specif vision. When I ask to send the cap file, is to see all the functionalities of specific equipment/model (include new ones) really have, and maybe map more interesting parts, including LG API V1 and sending commands, that Thinq-MQTT-Proxy doesn’t cover (at least, not fully). But, the cap file is not so important at all. As you said, I can consult the basic things in the existent projects. For me, the most important file is the datatraces, that contains the monitoring information sent by LG API. I can consult Thinq-MQTT-Proxy for some of the attributes come from LG API also, but is pretty much easier for me if I have the json file. With it, I can map the channels in almost 1 day.

Great ! Is good to know you have a lot of LG’s equipment. Then we can test in large scale :smiley:
Look, At the beginning, I was planning to release this Binding first to cover Air Conditiones, because is the devices I have in house to test. However, as a lot of people volunteered to help with other devices, I started to map others also. This diversity of devices obligated me to refactor the design of the Binding, to reuse better the common parts and turn easier to include a new device, if needed. This refactor is taking me some time, thus, I asking some patient to you guys for a new release with a functional version to finish the maping of Dryer and Washer Machines. I’m planning this to the next week and I will include you language/country as well, @Marty

2 Likes

Hi, guys.

I finished the refactoring and the Dryer & Washer Channel mapping. Feel free to check it out !. Visit my git’s and get the latest distribution of the Binding. See the link here:

1 Like

Vil give it a try later today… I´m off to bed now :smiley:

:+1: :sleeping:

1 Like

Hmm have some issues with the latest version.
I replaced the binding. After that, I removed my dryer, and did a rescan. My dryer appeared in inbox just fine and was added.
Then I removed my wm, and did a rescan. But it doesnt find it again.

Here is a output from the log:

2022-02-16 00:45:10.999 [ERROR] [al.discovery.LGThinqDiscoveryService] - Error trying to get device capabilities in discovery service. Fallback to the defaults values
java.lang.ClassCastException: Cannot cast org.openhab.binding.lgthinq.lgservices.model.dryer.DryerCapability to org.openhab.binding.lgthinq.lgservices.model.ac.ACCapability
	at java.lang.Class.cast(Class.java:3605) ~[?:?]
	at org.openhab.binding.lgthinq.lgservices.model.CapabilityFactory.create(CapabilityFactory.java:54) ~[?:?]
	at org.openhab.binding.lgthinq.lgservices.LGThinQAbstractApiClientService.getCapability(LGThinQAbstractApiClientService.java:235) ~[?:?]
	at org.openhab.binding.lgthinq.internal.discovery.LGThinqDiscoveryService.addLgDeviceDiscovery(LGThinqDiscoveryService.java:127) ~[?:?]
	at org.openhab.binding.lgthinq.internal.handler.LGThinQBridgeHandler$LGDevicePollingRunnable.lambda$0(LGThinQBridgeHandler.java:209) ~[?:?]
	at java.util.ArrayList.forEach(ArrayList.java:1541) [?:?]
	at org.openhab.binding.lgthinq.internal.handler.LGThinQBridgeHandler$LGDevicePollingRunnable.doConnectedRun(LGThinQBridgeHandler.java:204) [bundleFile:?]
	at org.openhab.binding.lgthinq.internal.handler.LGThinQBridgeHandler$PollingRunnable.run(LGThinQBridgeHandler.java:139) [bundleFile:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]
2022-02-16 00:45:11.007 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'lgthinq:202:4bb559ca4d:a6fc6dc7-34e8-147a-8f50-44cb8b0819e7' to inbox.
==> /var/log/openhab/events.log <==
2022-02-16 00:45:11.008 [INFO ] [openhab.event.InboxAddedEvent       ] - Discovery Result with UID 'lgthinq:202:4bb559ca4d:a6fc6dc7-34e8-147a-8f50-44cb8b0819e7' has been added.
2022-02-16 00:45:19.032 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'lgthinq:201:4bb559ca4d:592bd2a4-d3e7-16e9-a69f-44cb8b2e0c43' changed from ONLINE to OFFLINE (GONE)
2022-02-16 00:45:42.580 [INFO ] [openhab.event.InboxRemovedEvent     ] - Discovery Result with UID 'lgthinq:202:4bb559ca4d:a6fc6dc7-34e8-147a-8f50-44cb8b0819e7' has been removed.
2022-02-16 00:45:42.583 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'lgthinq:202:4bb559ca4d:a6fc6dc7-34e8-147a-8f50-44cb8b0819e7' changed from UNINITIALIZED to INITIALIZING
2022-02-16 00:45:43.424 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'lgthinq:202:4bb559ca4d:a6fc6dc7-34e8-147a-8f50-44cb8b0819e7' changed from INITIALIZING to ONLINE

It only found my dryer, and not my wm anymor :frowning:

After disable/enable the bridge, it found my wm again.

I’m sorry Kim. I forgot to test the discovery process after the refactory. I believed it would not be impacted. I was wrong. I fixed the cast problem, and I pushed a new version in the git repository.

Since I don’t have this real machines in house, I developed a simulator to act as the machine, but… you now there are limitations… the real tests depends on you guys.

1 Like

Just installed the new version @nemer. I’ll let you know the result. Do you think you can add the channels I suggested? I think EnergyMonitor especially could be really useful…

Ricky, I still didn’t map EnergyMonitor. Appears to be very particular for your model. To do so, I need the thinq-*-datatrace.json file to take my life easy :-). You can get this file putting the binding in debug. There are instructions in this topic about this. Look at this post: Contribution - LG ThinQ Binding - #52 by nemer
Then, disable/enabling the binding, you produce a file like this: thinq-XXXXXXXXX-datatrace.json.

Send to me, then I map this one for you.

Hey Nemer. I dont see EnergyMonitor channels either. Didn´t you get the energymonitor for my dryer/wm when I supplied you with the datatrace files?

Ky, @Kim_Andersen. Just to give a background about the Binding, the LG API provide an endpoint to monitor the equipments. This endpoint send a json data with structure called “snapshot”. This structure tells all the monitored properties the equipment is providing to LG.
Well, in your case, even the capability file pointing that there is a property called “EnergyMonitor”, I can’t see this property being provided by your equipment in the snapshot.
This is your snapshot file (datatrace):

{
   ...
   "snapshot":{
      "washerDryer":{
         "courseDryer24inchBase":"NOT_SELECTED",
         "initialBit":"INITIAL_BIT_OFF",
         "standby":"STANDBY_OFF",
         "initialTimeMinute":0.0,
         "processState":"DETECTING",
         "dnn_temp":"7",
         "smartPairing":"SMARTPAIRING_OFF",
         "error":"ERROR_NO",
         "dryLevel":"NO_DRYLEVEL",
         "dnn_precipitationProbability":"84",
         "downloadedCourseDryer24inchBase":"DEODORIZATION",
         "dnn_washingIndex":"30",
         "dnnReady":"DNNREADY_OFF",
         "remainTimeHour":0.0,
         "handIron":"HANDIRON_OFF",
         "reservation":"RESERVATION_OFF",
         "state":"POWEROFF",
         "antiCrease":"ANTICREASE_OFF",
         "reserveTimeMinute":0.0,
         "smartCourseDryer24inchBase":"NOT_SELECTED",
         "washingIndex":"30",
         "dnn_humidity":"74",
         "dnn_dust":"-",
         "dampDryBeep":"DAMPDRYBEEP_OFF",
         "ecoHybrid":"NO_ECOHYBRID",
         "remainTimeMinute":0.0,
         "reserveTimeHour":0.0,
         "childLock":"CHILDLOCK_OFF",
         "remoteStart":"REMOTE_START_OFF",
         "selfClean":"SELFCLEAN_OFF",
         "initialTimeHour":0.0
      },
      "mid":8.6413676E7,
      "online":true,
      "static":{
         "deviceType":"202",
         "countryCode":"DK"
      },
      "meta":{
         "allDeviceInfoUpdate":true,
         "messageId":"7NffXc7vQ0C0aKSgWhYpmg"
      },
      "timestamp":1.644508579255E12
   },
   "online":true,
   "platformType":"thinq2",
    ...
}

In my case, for example, I have an Air Conditioner, there is a specific field informing the value of the current been consumed by the device:

"airState.energy.onCurrent": 353,

That results in 0.35 KWh

I can’t see in your snapshot (of the WM or DR) any field representing the instant current consumption. But, in the capability file, your file has:

  "EnergyMonitoring": {
    "valueMapping": [
      "ecoHybrid",
      "dryLevel"
    ],
    "powertable": {
      "1": 1400,
      "2": 1600,
      "3": 1800,
      "4": 2200,
      "5": 2600
    }
  }

I think for your device, the Energy consumption is based on a table and program selected, i.e, there are no real current meter. I will do more research about it, but you can try to help me doing some tests in your WM, changing the program and see what’s changing in the LG App Energy Monitor. Some things like if the consumption is constant based on the program, etc.

Regards,

Hi Nemer.
You´re probably right. Its a very strange way (most probably just a static) the LG ThinQ app shows the energi used in the app. I actually never thought about that, as I kinda hoped openHAB would provide a better value for the energy consumption. But if its not there, it do makes sense… Sad LG didnt make it better :frowning:

Hi, Discovered this binding and finds it an amazing project. Currently, using the ThniqtoMqtt but a native binding would be awesome. I have installed it, but adding the bridge gives me an error.
The reason is The country code and Language.

Could you please add Country: “LU” and Language: “de-LU”

The error is : Error login into account. The reason is:{
“error” : {
“request” : “/emp/v2.0/account/session/xxxxxx@xx.xx”,
“code” : “MS.001.03”,
“message” : “LU”
}

Hi, @cmachtel. Good to know you’ve been interested in this binding. I’m planing to release a new version where the fields for country and language are opened (text). Maybe could be difficult for some people to configure, but for now, will help other people to contribute testing.
For you, I just release a new version with your country/language: https://github.com/nemerdaud/openhab-thinq-stuff/blob/main/org.openhab.binding.lgthinq-3.3.0-SNAPSHOT.jar

Enjoy and send feedback. BTW, what kind of devices are you trying to control ?

Thank you, it Works. I found my 4 AC. Will do some more test later but for now the devices are discovered and ON/Off works.

Really great work.
I have no others LG devices, but if I can help you, tell me.
Would also buy you a cup of coffee, but did not found any link for this :wink:

Great to hear about it ! Actually, I have 9 AC (V1 & V2) in my account. Then, for these devices, I think the binding is more mature. To control by widget, try the one provided by @hmerk (). I used it for myself, and its very nice. It needs some changes to work perfect with this Binding, but it’s working satisfactory for the main functions.


Controlling my ACs:

I’m planning to release other features for AC, like: control air direction, special functions (save energy, jet air, etc) and Energy Monitoring. If you have some suggestions, let me know.
About the coffee, I would be glad to a cup of one, without sugar in this link :wink: (Nemer Daud)

Cheers.