Contribution - LG ThinQ Binding

So I installed the latest binding but it does not show up on my binding list

You have to copy the bundle file to adds-on directory. You can restart OH, but it’s just in case.
If you are not seeing the bridge binding available, i suggest you to visit official documentation regarding custom binding install.

Just found this binding, been waiting for one for quite some time so huge thanks for working on this!

However, I can’t seem to get my fridge to work - it goes ONLINE and then OFFLINE after a few seconds with the following error in the openhab.log:

2023-09-17 21:37:47.919 [ERROR] [nternal.handler.LGThinQFridgeHandler] - Error updating thing Fridge/a9819ad0-6ba4-11e9-a78d-2c2bf94c177f from LG API. Thing goes OFFLINE until next retry: Error getting monitor data for the device:a9819ad0-6ba4-11e9-a78d-2c2bf94c177f

org.openhab.binding.lgthinq.internal.errors.LGThinqApiException: Error getting monitor data for the device:a9819ad0-6ba4-11e9-a78d-2c2bf94c177f

	at org.openhab.binding.lgthinq.internal.handler.LGThinQAbstractDeviceHandler.getSnapshotDeviceAdapter(LGThinQAbstractDeviceHandler.java:692) ~[?:?]

	at org.openhab.binding.lgthinq.internal.handler.LGThinQAbstractDeviceHandler.updateThingStateFromLG(LGThinQAbstractDeviceHandler.java:465) ~[?:?]

	at org.openhab.binding.lgthinq.internal.handler.LGThinQAbstractDeviceHandler$UpdateThingStateFromLG.run(LGThinQAbstractDeviceHandler.java:458) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]

	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]

	at java.lang.Thread.run(Thread.java:833) ~[?:?]

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 9

	at org.openhab.binding.lgthinq.lgservices.model.DefaultSnapshotBuilder.createFromBinary(DefaultSnapshotBuilder.java:89) ~[?:?]

	at org.openhab.binding.lgthinq.lgservices.model.devices.fridge.FridgeSnapshotBuilder.createFromBinary(FridgeSnapshotBuilder.java:41) ~[?:?]

	at org.openhab.binding.lgthinq.lgservices.model.devices.fridge.FridgeSnapshotBuilder.createFromBinary(FridgeSnapshotBuilder.java:1) ~[?:?]

	at org.openhab.binding.lgthinq.lgservices.model.DefaultSnapshotBuilder.createFromBinary(DefaultSnapshotBuilder.java:1) ~[?:?]

	at org.openhab.binding.lgthinq.lgservices.LGThinQAbstractApiClientService.getMonitorData(LGThinQAbstractApiClientService.java:342) ~[?:?]

	at org.openhab.binding.lgthinq.lgservices.LGThinQAbstractApiClientService.getMonitorData(LGThinQAbstractApiClientService.java:1) ~[?:?]

	at org.openhab.binding.lgthinq.internal.handler.LGThinQAbstractDeviceHandler.getSnapshotDeviceAdapter(LGThinQAbstractDeviceHandler.java:676) ~[?:?]

	... 8 more

The link to the appliance description is: https://eic.lgthinq.com:46030/api/webContents/modelJSON?modelName=2REF12EII_P_2&countryCode=WW&contentsId=JS0903072406417786&authKey=thinq

Datatrace:

{"deviceId":"a9819ad0-6ba4-11e9-a78d-2c2bf94c177f","deviceState":"E","format":"B64","returnCode":"0000","returnData":"AgQIAQICBAAB","stateCode":"S","workId":"n-a9819ad0-6ba4-11e9-a78d-2c2bf94c177f"}

Is there anything I’ve configured wrongly here, or is it not yet supported?

This is on openHAH 4, with the latest JAR file.

The binding for Thinq V1 Bridge with binary snapshot was not tested since it’s the first time someone try it out.
But, analysing your data, I can see the binary protocol says the snapshot data has 11 bytes, but based on your data, the device is returning only 8 bytes, thus the binding is breaking trying to read a byte that doesn’t exists.

These bytes refers to:

  • Smart Mode Status
  • LockingStatus : LOCK or UNLOCK
  • Active Saving Status : OFF or ON

So, I can suppose these last bytes are optional for the fridge, or even having this fields defined in the protocol, your fridge doesn’t support them.

O will change the binding e handle this case to break the parser if no more data is available, then you let me know if it works.

Regards.

Can you tell me the frontpanel’s target temperatures for the fridge and the refrigerator related to this snapshot data ?

Thanks for the quick reply!
Target temp is set to 3 C and -23 C respectively.

You can try the latest version and see if it fixes this issue.

1 Like

Thanks, now it shows up as online!
I get some errors in the log though, and no temps on the items:

2023-09-18 18:02:04.699 [WARN ] [penhab.core.library.items.NumberItem] - Failed to update item 'LG_Kylskap_Fridge_Setpoint_Temperature' because '4' could not be converted to the item unit '°C'
2023-09-18 18:02:04.701 [WARN ] [penhab.core.library.items.NumberItem] - Failed to update item 'LG_Kylskap_Freezer_Setpoint_Temperature' because '8' could not be converted to the item unit '°C'

I created the equipment and items through the UI by just accepting defaults throughout.
I could correct the error by changing the item type Number:Temperature → Number, but it still doesn’t do the ENUM lookup from the JSON file. Should it?

Eg. I get the value “4” for fridge (correct), which in the lookup table should translate into 3°C in the UI:

		"TempRefrigerator_C": {
			"type": "Enum",
			"default": "10",
			"_comment": "Temperature Unit :℉ or ℃ ",
			"option": {
				"1": "6",
				"2": "5",
				"3": "4",
				"4": "3",
				"5": "2",
				"6": "1",
				"7": "0"
			}
		},

Ofc I can hard code this, from that perspective all is good - thanks again!

Hi, @qianc .

I did some changes in the convertions, can you try again with the new binding ?

Regards

Seems like the updated version is only for 4.1 snapshot?
I run 4.0 stable.

Tried it but get the following error in the log:

2023-09-23 13:13:52.441 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/openhab/addons/org.openhab.binding.lgthinq-4.1.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.lgthinq [322]
  Unresolved requirement: Import-Package: javax.measure; version="[2.2.0,3.0.0)"
	at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.18.0.jar:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[org.eclipse.osgi-3.18.0.jar:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) ~[?:?]

Yes. To explain better, the binding dependencies are inherited from the oh adds-on project. If there are changes in the top of the dependencies, its impact indirectly the binding.

I will build the binding with 4.0 OH version and update in my repo to do not impact who want to stay in the 4.0 version.

OK, guys. For the 4.0.X version, you can try the 4.0.0 version in the repository.

Regards.

Thanks!
No errors now when creating a new item, so that’s good. But there’s still no lookup of the value, so whatever’s being displayed is wrong unless I manually add the associated state metadata.

This is a screenshot at my two items. The lower one (ending in 2) is created simply through the UI. The first one I’ve added metadata (“State description”) for to map value to actual temperature, as in the LG JSON file.

This is how my mapping looks like (8 corresponds to -23):
image

Can you share with me the thinq-XXX-datatrace.json and thinq-XXXX-cap.json files ?

Has not changed from the post above, Contribution - LG ThinQ Binding - #516 by qianc

First shot: in order to compile the binding I needed to change the pom.xml

diff --git a/bundles/org.openhab.binding.lgthinq/pom.xml b/bundles/org.openhab.binding.lgthinq/pom.xml
index 2efd0b0a55..527af15e6d 100644
--- a/bundles/org.openhab.binding.lgthinq/pom.xml
+++ b/bundles/org.openhab.binding.lgthinq/pom.xml
@@ -6,7 +6,7 @@
   <parent>
     <groupId>org.openhab.addons.bundles</groupId>
     <artifactId>org.openhab.addons.reactor.bundles</artifactId>
-    <version>4.0.0-SNAPSHOT</version>
+    <version>4.1.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>org.openhab.binding.lgthinq</artifactId>
@@ -38,6 +38,11 @@
       <version>2.32.0</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>javax.measure</groupId>
+      <artifactId>unit-api</artifactId>
+      <version>1.0</version>
+    </dependency>
   </dependencies>
 
 </project>

After that the addon loads fine in OH and I’m able to switch on/off my AC.

The sources are not updated with the latest binaries delivered.
So, the version 4.1.0 was not pushed to the repository yet, but the binaries org.openhab.binding.lgthinq-4.1.0-SNAPSHOT.jar was. It’s because before I push the source code, I have to test (i.e. you guys test) the changes and fixes first, then I can close a release and push the source code.
You don’t need to compile the source couse. It’s not the latest version, except if you are doing some customs.

Regards.

Hi mr. Nemer, I’ve configured the bridge like this :

Bridge lgthinq:bridge:LGAccount “LG ThinQ Account”
[ username=“…”, password=“…”, language=“it-IT”, country=“IT”, pollingIntervalSec=60 ] {

101    ACEscritorio    "Frigo"    [ 
    device_id="6b4636d3-d406-1ed4-91b4-1c39298f351e",
    model_url_info="https://objectcontent.lgthinq.com/e51e3dd4-8a95-48ff-8a52-a3a7ecf12cc8?hdnts=exp=1750561257~hmac=48be78d16de78f918b3bbdd7b628a5ab0e3419ee915276e67784665aeedd9cfa",
    platform_type="thinq2",
    polling-period-poweron-seconds=60,
    polling-period-poweroff-seconds=60,
    polling-extra-info-period-poweron-seconds=60,
    polling-extra-info-period-poweroff-seconds=0
]

}

and items like this :

// Elenco Items per Things LG THIN Q
Contact FrigoSomeDoorOpen “Porta APERTA” (GR_LgThinQ_FRIGO) {channel=“lgthinq:101:LGAccount:ACEscritorio:some-door-open”}
Number:Temperature FrigoFreezerTemperature “Setpoint FRIGO [%.0f %unit%]” (GR_LgThinQ_FRIGO) {channel=“lgthinq:101:LGAccount:ACEscritorio:freezer-temperature”}
Number:Temperature FrigoFridgeTemperature “Setpoint CONGELATORE [%.0f %unit%]” (GR_LgThinQ_FRIGO) {channel=“lgthinq:101:LGAccount:ACEscritorio:fridge-temperature”}
String FrigoTempUnit “Temp. unit” (GR_LgThinQ_FRIGO) {channel=“lgthinq:101:LGAccount:ACEscritorio:temp-unit”}

The result is that bridge and frigo are always at ONLINE status,
but temperatures are wrong.
Now I have 5°C in fridge and -18°C in freezer,
but the binding says 4°C and 3° respectively.

What I’m Wrong ???

I also tried to configure all by UI but the result is the same,
and also often via UI the fridge goes OFFLINE …

many thanks

No worry. This is a bug I’m fixing for the new release i expect to delivery this week. I lef you know

Hi, many thanks for creating this binding.
I have several LG devices which are detected correctly (AC, washer, fridge, freezer). I also have an LG Dishwasher (model: DF455HSS.AASQEES) which doesn’t show up in Things discovered, nor is Dishwasher in the add thing manually list so I assume it’s not supported yet.
Is there anything I can do to help get this added?
Thanks again, Pete.