LGWebOS Binding (for LG WebOS TVs)

@sprehn
Hi! Sorry for being away for long time - I went for fishing. Tested new version - still no succes. Here are the steps I did:

1. Downloaded new version of binding “org.openhab.binding.connectsdk_1.8.0.201601091401.jar”
2. Put it to the addons folder
3. Edited items file - added 4 test items

Switch LG1_vol_up       "Volume Up 1" { connectsdk="192.168.0.30:VolumeControl:up", autoupdate="false" }
Switch LG1_vol_down     "Volume Down 1" { connectsdk="192.168.0.30:VolumeControl:down",          autoupdate="false"}
Switch LG1_vol_mute       "Mute 1" { connectsdk="192.168.0.30:VolumeControl:mute" }
Switch LG1_power      "Power" { connectsdk="192.168.0.30:PowerControl:power", autoupdate="false" }

4. Edited sitemap - added lines

Switch item=LG1_vol_up mappings=[ON="Up"]
Switch item=LG1_vol_down mappings=[ON="Down"]
Switch item=LG1_vol_mute
Switch item=LG1_power

5. Restarted openhab service
6. Turned on the TV and started to click on switches from UI - nothing happened
7. Looked through openhab event log - there were no events for LG1_* items
8. Looked through openhab log and uploaded it to my google drive
Openhab still can’t see TV items, though 13th line says that opensdk binding is activated: 2016-01-10 20:34:00.912 [DEBUG] [b.c.internal.ConnectSDKBinding] - activated.
9. Rebooted the server, renamed the binding to more short variant “org.openhab.binding.connectsdk_1.8.0.jar” - no result.

P.S. With previous version of binding “Welcome to Openhab” frame appeared in the top right TV screen corner once per 30 minutes, with the updated version I didn’t notice the frame appearance.

Could you send me your items file? I suspect some sort of syntax error in it.

Regarding your observation on “Welcome to Openhab”. In the new version the binding only connects to the TV if items configured for it are found. Only if a ToastControl item is bound, then it sends the welcome message.

The good news is, the communication between openhab and your TV is already working, just need to sort out the items configuration…

Sure. Here you are:
https://drive.google.com/file/d/0Bzj7KW1HWFtSZ1dTYUhwQ0NwRTQ/view?usp=sharing

try removing this "#Colorpicker for rgb bulbs at bridge2“ or comment it out with two slashes //

Correct! now the bus started to receive commands for LG items. Will continue testing right now

Now I have (made copy of items for second TV )

2016-01-10 22:51:27.110 [DEBUG] [b.c.internal.ConnectSDKBinding] - activated
2016-01-10 22:51:32.673 [DEBUG] [b.c.internal.ConnectSDKBinding] - internalReceiveCommand(LG1_vol_up,ON) is called!
2016-01-10 22:51:32.676 [WARN ] [b.c.internal.ConnectSDKBinding] - 192.168.0.30 not found under connect sdk devices. Skipping item LG1_vol_up
2016-01-10 22:51:34.225 [DEBUG] [b.c.internal.ConnectSDKBinding] - internalReceiveCommand(LG2_vol_up,ON) is called!
2016-01-10 22:51:34.226 [WARN ] [b.c.internal.ConnectSDKBinding] - 192.168.0.31 not found under connect sdk devices. Skipping item LG2_vol_up
2016-01-10 22:51:35.639 [DEBUG] [b.c.internal.ConnectSDKBinding] - internalReceiveCommand(LG1_vol_down,ON) is called!
2016-01-10 22:51:35.641 [WARN ] [b.c.internal.ConnectSDKBinding] - 192.168.0.30 not found under connect sdk devices. Skipping item LG1_vol_down
2016-01-10 22:51:37.566 [DEBUG] [b.c.internal.ConnectSDKBinding] - internalReceiveCommand(LG2_vol_down,ON) is called!
2016-01-10 22:51:37.568 [WARN ] [b.c.internal.ConnectSDKBinding] - 192.168.0.31 not found under connect sdk devices. Skipping item LG2_vol_down
2016-01-10 22:51:39.276 [DEBUG] [b.c.internal.ConnectSDKBinding] - internalReceiveCommand(LG1_vol_mute,ON) is called!
2016-01-10 22:51:39.278 [WARN ] [b.c.internal.ConnectSDKBinding] - 192.168.0.30 not found under connect sdk devices. Skipping item LG1_vol_mute

in Openhab log

Good. Messages only mean, that connect sdk currently does not see a device under this IP. Are the TVs on?

Sure, I’m watching them)

They are seen for both me and openhab

Can you please turn one off, wait a few seconds and turn it on again. In the new version, the binding will only connect to the device if items are present. If the TV was on when you made the last config change, we are probably not connected yet. Looking for something like this in the logs:

18:04:01.522 INFO o.o.b.c.i.ConnectSDKBinding[:158]- added: {“modelName”:“LG Smart TV”,“lastConnected”:9223372036854775807,“lastKnownIPAddress”:“192.168.1.128”,“id”:“c5cf1075-cf87-4e39-aa7a-70e7911a02c7”,“services”:{“6da62662-1369-a82d-95c7-353c235ed503”:{“description”:{“filter”:“urn:lge-com:service:webos-second-screen:1”,“modelName”:“LG Smart TV”,“port”:1140,“ipAddress”:“192.168.1.128”,“serviceId”:“webOS TV”,“uuid”:“6da62662-1369-a82d-95c7-353c235ed503”,“version”:“4.1.0”,“friendlyName”:“Fernseher”},“class”:“WebOSTVService”,“config”:{“clientKey”:“c444b6aa0457989e98156ea3fedd5929”,“lastDetection”:9223372036854775807,“UUID”:“6da62662-1369-a82d-95c7-353c235ed503”,“class”:“WebOSTVServiceConfig”}}},“lastDetection”:1452445441,“friendlyName”:“Fernseher”}

followed by a

18:04:01.845 INFO o.o.b.c.i.ConnectSDKBinding[:175]- Device ready: {“modelName”:“LG Smart TV”, …

Understood. I remember such lines in log when testing previous binding version. My family went to sleep already, I’ll check it tomorow after work. Thanks

I just installed the binding. Pairing and control of the tv works as far as i tested (volume control eg is okay).
I’m mostly interested in sending “toast” messages to tv, but they don’t appear.
My rule looks like:

rule “LG Test”
when
Item Presence_State changed
then
logInfo(“Test”, “hello”)
LG_TV0_Toast.postUpdate(“Test”)
end

I can see the log message, but nothing on the tv screen.

Item definition is:


Switch LG_TV0_MediaForward “Forward” { connectsdk=“lgsmarttv:MediaControl:forward”, autoupdate=“false” }
Switch LG_TV0_MediaStop “Stop” { connectsdk=“lgsmarttv:MediaControl:stop”, autoupdate=“false” }

String LG_TV0_Input “Input” { connectsdk=“lgsmarttv:ExternalInputControl:input” }

String LG_TV0_Toast { connectsdk=“lgsmarttv:ToastControl:toast” }

Nice… instead of postUpdate use sendCommand. LG_TV0_Toast.sendCommand(“Test”)

no that does not work :frowning:

Any Ideas?

when you turn on your TV, few seconds later, do you see the “Welcome to Openhab” toast message?
If that is not the case, then the item with the ToastControl is not correctly configured. I cannot spot any mistake in your item configuration posted above.
If you see that welcome message, then it is only a problem with your rule. On the wiki page linked above I have added an example on toast messages that I am using.

otherwise it would help to see your openhab.log, ideally with debugging.
<logger name="org.openhab.binding.connectsdk" level="DEBUG"/> <logger name="com.connectsdk" level="DEBUG"/>

No, I can’t see the welcome message. My TV asks for binding, but then nothing else happens. Volume, channel selection eg is still working.
Here is the log:

2016-01-11 22:10:54.909 INFO  o.o.m.script.Presence State[:53]- Alle weg
2016-01-11 22:10:54.930 INFO  org.openhab.model.script.Test[:53]- hello
2016-01-11 22:10:54.948 DEBUG o.o.b.c.i.ConnectSDKBinding[:112]- internalReceiveCommand(LG_TV0_Toast,Test) is called!
2016-01-11 22:10:54.959 INFO  o.o.b.e.internal.ExecBinding[:319]- executed commandLine '[/bin/sh, -c, echo 1 | sudo tee /sys/class/leds/orange:ph20:led2/brightness]'
2016-01-11 22:10:54.953 INFO  o.o.model.script.Flurlicht An[:53]- Entferne Timer 'Flurlicht An'
2016-01-11 22:10:54.982 INFO  o.o.m.script.Rolllaeden runter[:53]- Erzeuge Timer 'Rolllaeden runter' um 2016-01-11T17:12:35.032+01:00
2016-01-11 22:10:54.997 INFO  o.o.model.script.Flurlicht An[:53]- Erzeuge Timer 'Flurlicht An' um 2016-01-11T16:42:35.032+01:00
2016-01-11 22:10:55.005 INFO  o.o.m.script.Rolllaeden runter[:53]- Fuehre Timer 'Rolllaeden runter' aus
2016-01-11 22:10:55.032 INFO  o.o.model.script.Flurlicht An[:53]- Fuehre Timer Flurlicht An aus
2016-01-11 22:10:59.201 INFO  o.o.m.script.Presence Simon[:53]- Simons IPhone hat sich ins WLAN eingebucht
2016-01-11 22:10:59.643 INFO  o.o.model.script.Presence Moni[:53]- Monis IPhone hat sich ins WLAN eingebucht
2016-01-11 22:11:02.232 INFO  o.o.m.script.Presence State[:53]- Jemand ist da
2016-01-11 22:11:02.251 INFO  o.o.model.script.Flurlicht Aus[:53]- Schalte Flurlicht aus
2016-01-11 22:11:02.256 INFO  o.o.model.script.Flurlicht Aus[:53]- Entferne Timer 'Flurlicht An'
2016-01-11 22:11:02.260 INFO  org.openhab.model.script.Test[:53]- hello
2016-01-11 22:11:02.267 INFO  o.o.m.script.Rolllaeden runter[:53]- Erzeuge Timer 'Rolllaeden runter' um 2016-01-11T17:12:35.032+01:00
2016-01-11 22:11:02.275 INFO  o.o.b.e.internal.ExecBinding[:319]- executed commandLine '[/bin/sh, -c, echo 0 | sudo tee /sys/class/leds/orange:ph20:led2/brightness]'
2016-01-11 22:11:02.273 DEBUG o.o.b.c.i.ConnectSDKBinding[:112]- internalReceiveCommand(LG_TV0_Toast,Test) is called!
2016-01-11 22:11:02.300 INFO  o.o.m.script.Rolllaeden runter[:53]- Fuehre Timer 'Rolllaeden runter' aus

well, first we can conclude item LG_TV0_Toast is associated with the binding and your command to LG_TV0_Toast was received correctly by the binding

2016-01-11 22:10:54.948 DEBUG o.o.b.c.i.ConnectSDKBinding[:112]- internalReceiveCommand(LG_TV0_Toast,Test) is called!

In the ToastControlToast hook onReceiveCommand, which handles the received command event it does the following

if (matchClassAndProperty(clazz, property) && d.hasCapabilities(ToastControl.Show_Toast)) {...}

clazz and property in your items configuration look fine. Am a bit lost myself. Can you check earlier in your log file (or turn your TV off, wait a minute until you see the “Device disconnected” in the log, and on again)

You should see something like this:
added
Pairing required // if TV has not been paired before
Device ready

22:35:28.036 INFO o.o.b.c.i.ConnectSDKBinding[:158]- added: {"modelName":"LG Smart TV","lastConnected":9223372036854775807,"lastKnownIPAddress":"192.168.1.128","id":"721baf32-c1c7-4b54-976b-c790953b7220","services":{"6da62662-1369-a82d-95c7-353c235ed503":{"description":{"filter":"urn:lge-com:service:webos-second-screen:1","modelName":"LG Smart TV","port":1955,"ipAddress":"192.168.1.128","serviceId":"webOS TV","uuid":"6da62662-1369-a82d-95c7-353c235ed503","version":"4.1.0","friendlyName":"Fernseher"},"class":"WebOSTVService","config":{"lastDetection":1452548128,"UUID":"6da62662-1369-a82d-95c7-353c235ed503","class":"ServiceConfig"}}},"lastDetection":1452548128,"friendlyName":"Fernseher"} 22:35:28.398 INFO o.o.b.c.i.ConnectSDKBinding[:165]- Pairing required. 22:35:30.655 INFO o.o.b.c.i.ConnectSDKBinding[:175]- Device ready: {"modelName":"LG Smart TV","lastConnected":1452548130,"lastKnownIPAddress":"192.168.1.128","id":"721baf32-c1c7-4b54-976b-c790953b7220","services":{"6da62662-1369-a82d-95c7-353c235ed503":{"description":{"filter":"urn:lge-com:service:webos-second-screen:1","modelName":"LG Smart TV","port":1955,"ipAddress":"192.168.1.128","serviceId":"webOS TV","uuid":"6da62662-1369-a82d-95c7-353c235ed503","version":"4.1.0","friendlyName":"Fernseher"},"class":"WebOSTVService","config":{"clientKey":"3805bd049cdcfcdf4176e87a398dca5f","serverCertificate":"MIIDTDCCAjQCCQDOub0OJqQSczANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzETMBEGA1UECAwKTmV3IEplcnNleTEjMCEGA1UECgwaTEcgRWxlY3Ryb25pY3MgVS5TLkEsIEluYy4xHzAdBgNVBAMMFkxHX1RWXzJjNTM5NDUyMWExMDdlOGMwHhcNMTUxMTEwMjAxMTQzWhcNMzUxMTA1MjAxMTQzWjBoMQswCQYDVQQGEwJVUzETMBEGA1UECAwKTmV3IEplcnNleTEjMCEGA1UECgwaTEcgRWxlY3Ryb25pY3MgVS5TLkEsIEluYy4xHzAdBgNVBAMMFkxHX1RWXzJjNTM5NDUyMWExMDdlOGMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9yn3bSc1sGd9sznF6VoDtmQBbMBhYlZ2TMk8WXFC/JWtM0PqnBhIqPK/pi5EPT6oynOSn6ovrq/aVKmY+6FwHFcTcombIPltRCjiTjgMXCX2Ndt+10fE9iKUxWbkelz3rFY5YbTtpttdjh1FZJ5DV/DTOIfxI8b/ejKtEXwtqRF5WeN+USbsbeM157F3siycUaWj43Ha5DRD5CBKHo5u5KrD+wR39/sCCJXH2beSnSj2Hwloktq8Pyt/yHkpHfx+D+phDtmn10zfgxt4iwd5CfqpL6bUroy8w3MPZjg+wQPfeaeXPniTVKLu6R/A6LgbRA/c81ZSdB9GiUULwkV7fAgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAGw91by2/D2MIfLHW7H640O+YnUbNqntzDF08Yr1Y+yZ/vqHSFjsKtBt8abNmrFUOjJzA7006SF/7dzQCM3qlOF72nXi95P4oYBdc3JrTb/6+dGAgRQDczAPIp4Aie+/4UBdWawcrb69Oku4YmImsn0bDgYTjHR932u0YZCuKxNcwpZNVBn6mn+3r5AhwfsW5u5HF0cx8qRkIgyl6Vc+7dkA8ouXItLFhEhj0WV+bgvhItLRNhXu7Bf8g2nAxrbLYKweYasDQphGFwkqOhd71nwR7Mfdsu4rrLBIpJJlr9MXY0oQOutiNrDvp4R6K3xjCsRrhEvL7Q2fyGOXc2yz7Mg=","lastDetection":9223372036854775807,"UUID":"6da62662-1369-a82d-95c7-353c235ed503","class":"WebOSTVServiceConfig"}}},"lastDetection":1452548128,"friendlyName":"Fernseher"} 22:35:30.657 DEBUG o.o.b.c.i.b.AbstractOpenhabConnectSDKPropertyBridge[:50]- Subscribed VolumeControl:volume listener on IP: 192.168.1.128 22:35:30.659 DEBUG o.o.b.c.i.b.AbstractOpenhabConnectSDKPropertyBridge[:50]- Subscribed VolumeControl:mute listener on IP: 192.168.1.128 22:35:30.661 DEBUG o.o.b.c.i.b.AbstractOpenhabConnectSDKPropertyBridge[:50]- Subscribed TVControl:channel listener on IP: 192.168.1.128 22:35:31.767 DEBUG o.o.b.c.i.b.AbstractOpenhabConnectSDKPropertyBridge[:136]- Successfully set ToastControl:toast: {"returnValue":true,"toastId":"com.webos.service.apiadapter-1452548131472"}.

One more idea: Could you set the exact IP instead of the hostname in our item config? Your config with DNS resolution should work, just want to rule out this variable

I think i know whats wrong…

Please make sure you are using the lastest version. I think that is it.

GitHub returns 404
Maybe missing permissions?