LGWebOS Binding (for LG WebOS TVs)

new version, which should handle your error (B) gracefully, without disconnecting the tv

That seems to have fixed my problem. Both of my TVā€™s added and connected normally. I will say that one of the reasons I may have errors with my item definitions is because I currently only use this binding for on/off and source functionality. I donā€™t use the volume or channels on my TV.

Thank you, Sebastian!

1 Like

Exciting news: pull request #6060 was merged. So we will see this new version in snapshot builds.

2 Likes

Hi, sorry it took so long to replyā€¦to much work!
There is only a set of braces {} in the StoredDevice file, what is the format of what it should have:
the TVs are:

The TVā€™s are defined in the ā€œorg.eclipse.smarthome.core.thing.Thing.jsonā€
File

{
  "lgwebos:WebOSTV:93d6e248-596d-40b2-bf27-2f93e0c70c1b": {
    "class": "org.eclipse.smarthome.core.thing.internal.ThingImpl",
    "value": {
      "label": "PBA TV1",
      "channels": [
        {
          "acceptedItemType": "Switch",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "power"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "powerType"
            ]
          },
          "label": "Power",
          "description": "Via this binding TV can only be powered off, not on.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Switch",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "mute"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "muteType"
            ]
          },
          "label": "Mute",
          "description": "Current Mute Setting",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Dimmer",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "volume"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "volumeType"
            ]
          },
          "label": "Volume",
          "description": "Current Volume Setting",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Number",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "channel"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "channelType"
            ]
          },
          "label": "Channel",
          "description": "Current Channel",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "String",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "channelName"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "channelNameChannelType"
            ]
          },
          "label": "Channel Name",
          "description": "Current Channel Name",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "String",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "toast"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "toastType"
            ]
          },
          "label": "Toast",
          "description": "Send a message onto the TV screen.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Player",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "mediaPlayer"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "mediaPlayerType"
            ]
          },
          "label": "Media Control",
          "description": "Control media (e.g. audio or video) playback",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "Switch",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "mediaStop"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "mediaStopType"
            ]
          },
          "label": "Stop",
          "description": "Stop Playback",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        },
        {
          "acceptedItemType": "String",
          "kind": "STATE",
          "uid": {
            "segments": [
              "lgwebos",
              "WebOSTV",
              "93d6e248-596d-40b2-bf27-2f93e0c70c1b",
              "appLauncher"
            ]
          },
          "channelTypeUID": {
            "segments": [
              "lgwebos",
              "appLauncherChannelType"
            ]
          },
          "label": "Application",
          "description": "Start application and monitor running applications.",
          "configuration": {
            "properties": {}
          },
          "properties": {},
          "defaultTags": []
        }
      ],
      "configuration": {
        "properties": {
          "deviceId": "93d6e248-596d-40b2-bf27-2f93e0c70c1b"
        }
      },
      "properties": {},
      "uid": {
        "segments": [
          "lgwebos",
          "WebOSTV",
          "93d6e248-596d-40b2-bf27-2f93e0c70c1b"
        ]
      },
      "thingTypeUID": {
        "segments": [
          "lgwebos",
          "WebOSTV"
        ]
      }
    }
  },

Hello,

I had to pair my Lg TV, but in the current snapshot of openhab I get the follwing error:

Thing 'lgwebos:WebOSTV:a50d3c74-41f9-1f34-5119-b22ccd48f1f5' has been updated.

2019-10-10 19:07:50.291 [hingStatusInfoChangedEvent] - 'lgwebos:WebOSTV:a50d3c74-41f9-1f34-5119-b22ccd48f1f5' changed from OFFLINE: TV is off to ONLINE: Registering - You may need to confirm pairing on TV.

2019-10-10 19:07:50.317 [me.event.ThingUpdatedEvent] - Thing 'lgwebos:WebOSTV:a50d3c74-41f9-1f34-5119-b22ccd48f1f5' has been updated.

2019-10-10 19:07:50.318 [hingStatusInfoChangedEvent] - 'lgwebos:WebOSTV:a50d3c74-41f9-1f34-5119-b22ccd48f1f5' changed from ONLINE: Registering - You may need to confirm pairing on TV. to ONLINE: Connected

2019-10-10 19:07:50.325 [vent.ItemStateChangedEvent] - TV_Living_Power changed from OFF to ON

2019-10-10 19:07:52.965 [hingStatusInfoChangedEvent] - 'lgwebos:WebOSTV:a50d3c74-41f9-1f34-5119-b22ccd48f1f5' changed from ONLINE: Connected to OFFLINE (COMMUNICATION_ERROR): Connection Failed: Text message size [2258187] exceeds maximum size [2097152]

2019-10-10 19:07:52.967 [hingStatusInfoChangedEvent] - 'lgwebos:WebOSTV:a50d3c74-41f9-1f34-5119-b22ccd48f1f5' changed from OFFLINE (COMMUNICATION_ERROR): Connection Failed: Text message size [2258187] exceeds maximum size [2097152] to OFFLINE: TV is off

Of course, Iā€™ve confirmed the paing on the TV.
This appears every 3 seconds in the log.
When I switch back to 2.4 stable of the binding , everything works fine.
Regards,
Olli

Thank you Olli for this valuable feedback

the return message size is too big.
Iā€™ll have to increase it or figure out a smarter way to handle this

for your reference

Hello Sebastian,
the issue seems to be solved. Everything is looking good now :slight_smile: .
Thank you for your great support.

Regards,
Olli

Hello Sebastian,

I found another Problem with my new LG TV (webOS 4.5).
When I switch off the TV via Remote Control, the Thing goes OFFLINE, but it never comes back ONLINE.
I have to restart the binding/openhab to get it ONLINE again.

This will not happen, when I switch the TV off via openhab.

Regards,
Olli

P.S.: Here is the the debug log when this happensā€¦it seems the binding stays in status ā€œConnectingā€.

2019-10-27 12:40:24.509 [DEBUG] [ng.lgwebos.internal.TVControlChannel] - Channel 8 - 1LIVE diGGi (Internet)
2019-10-27 12:40:24.510 [DEBUG] [ng.lgwebos.internal.TVControlChannel] - Channel 9 - WDR Event (Internet)
2019-10-27 12:40:31.109 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - WebSocket Closed - Code: 1001, Reason: server shutting down
2019-10-27 12:40:31.114 [DEBUG] [.lgwebos.internal.BaseChannelHandler] - Unsubscribed org.openhab.binding.lgwebos.internal.VolumeControlVolume on IP: lgwebos:WebOSTV:351e981f-4b8e-2d38-bf49-c6443119c0c1
2019-10-27 12:40:31.117 [DEBUG] [.lgwebos.internal.BaseChannelHandler] - Unsubscribed org.openhab.binding.lgwebos.internal.LauncherApplication on IP: lgwebos:WebOSTV:351e981f-4b8e-2d38-bf49-c6443119c0c1
2019-10-27 12:40:31.119 [DEBUG] [.lgwebos.internal.BaseChannelHandler] - Unsubscribed org.openhab.binding.lgwebos.internal.TVControlChannel on IP: lgwebos:WebOSTV:351e981f-4b8e-2d38-bf49-c6443119c0c1
2019-10-27 12:40:31.122 [DEBUG] [.lgwebos.internal.BaseChannelHandler] - Unsubscribed org.openhab.binding.lgwebos.internal.VolumeControlMute on IP: lgwebos:WebOSTV:351e981f-4b8e-2d38-bf49-c6443119c0c1
2019-10-27 12:40:31.124 [DEBUG] [.lgwebos.internal.BaseChannelHandler] - Unsubscribed org.openhab.binding.lgwebos.internal.TVControlChannelName on IP: lgwebos:WebOSTV:351e981f-4b8e-2d38-bf49-c6443119c0c1
2019-10-27 12:40:31.128 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Connecting to: ws://172.16.1.44:3000
2019-10-27 12:40:41.132 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
2019-10-27 12:40:51.135 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
2019-10-27 12:41:01.139 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
2019-10-27 12:41:11.142 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
....
2019-10-27 12:44:51.193 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
2019-10-27 12:45:01.197 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
2019-10-27 12:45:11.199 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
2019-10-27 12:45:14.677 [DEBUG] [very.LGWebOSUpnpDiscoveryParticipant] - Found LG WebOS TV: (RemoteDevice) Identity: (RemoteDeviceIdentity) UDN: uuid:351e981f-4b8e-2d38-bf49-c6443119c0c1, Descriptor: http://172.16.1.44:1060/, Root: true
2019-10-27 12:45:21.200 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING
2019-10-27 12:45:31.202 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Not trying to connect. Current state is: CONNECTING

it takes some time to shut down, as well as to boot up. think of the tv as a small linux box. only after it is fully started it will respond to api requests

I think in this case itā€™s not a matter of time.
Sometimes after switching off the TV this will occur in the debug log for hours:

Not trying to connect. Current state is: CONNECTING

When I start the TV (WOL or RC) hours after switching it off, I still get the message and the binding stays offline.

Normally this message occurs in the debug log:

Connecting to: ws://172.16.1.44:3000

Then everything works fineā€¦

Regards,
Olli

Iā€™ve tested it with 2.4 stable.There arenā€™t these Problems.
2.5 has problems with the Thing status. It always stays ONLINE when the TV is switched off, until it gets a timeout after 5 mins , then the Thing goes offline. But im most cases the binding doesnā€™t come ONLINE after switching on.
2.4. ist going OFFLINE instantly after switching off the TV and it comes ONLINE after a couple of seconds when switching the tv on.

I use 2.5.0.M4 (Openhab & binding version) and the status (ON/OFF) updates within a few seconds.

Hello,
is your TV webOS 3 or 4.5 ?
My older TV with webOS 3 works fine with the current snapshot. My newer TV with 4.5 does not.

Hi,

please use the version, which comes with openhab snapshot builds or pre-releases, donā€™t use the snapshot I released in my github account.

In the 2.4 version ONLINE or OFFLINE was based on UPNP discovery results.

In the new version ONLINE or OFFLINE is determined by the ability of OH to estabilsh the websocket connection to the device over the network. Once the network connection breaks it is OFFLINE until OH is able to connect back again.

I wonder if the 4.5 device remains ā€œonlineā€ from a network perspective for 5 min until it finally fully shuts down. Could you do a short test and shut down the 4.5 TV, and maybe 15 sec later pull the power cord. I bet it will show as OFFLINE. If that is the case, we would have to figure out a way to query that state via the api.

Hi,
in my tests I always use the latest openhab snapshot builds with a webOs 4.5 based TV.

So, here are my results:

Switch TV off:

2019-10-28 23:11:47.866 [DEBUG] [very.LGWebOSUpnpDiscoveryParticipant] - Found LG WebOS TV: (RemoteDevice) Identity: (RemoteDeviceIdentity) UDN: uuid:351e981f-4b8e-2d38-bf49-c6443119c0c1, Descriptor: http://172.16.1.44:1458/, Root: true
2019-10-28 23:11:48.246 [vent.ItemStateChangedEvent] - TV_Bed_Application changed from com.webos.app.hdmi1 to

Pulled the plug after 15 secondsā€¦nothing happens

five minutes later:

2019-10-28 23:16:48.245 [hingStatusInfoChangedEvent] - 'lgwebos:WebOSTV:351e981f-4b8e-2d38-bf49-c6443119c0c1' changed from ONLINE: Connected to OFFLINE (COMMUNICATION_ERROR): Connection Failed: java.util.concurrent.TimeoutException: Idle timeout expired: 300000/300000 ms

2019-10-28 23:16:48.252 [hingStatusInfoChangedEvent] - 'lgwebos:WebOSTV:351e981f-4b8e-2d38-bf49-c6443119c0c1' changed from OFFLINE (COMMUNICATION_ERROR): Connection Failed: java.util.concurrent.TimeoutException: Idle timeout expired: 300000/300000 ms to OFFLINE: TV is off

Now 2 different things could happen:

-Binding comes online when powering on the TV. This is the expected behaviour. In this case I get this log until I switch the TV on:

 [DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Connecting to: ws://172.16.1.44:3000

 [DEBUG] [ebos.internal.handler.LGWebOSHandler] - Connection failed - error: Connect Timeout

-Binding remains offline: Here I get this log:

[DEBUG] [bos.internal.handler.LGWebOSTVSocket] - Connecting to: ws://172.16.1.44:3000
[DEBUG] [ebos.internal.handler.LGWebOSHandler] - Not trying to connect. Current state is: CONNECTING

Hope it helpsā€¦
Olli

mine is webOS4.5

I suspect this is the SSDP notification that the device is going offline. Since the 2.4 binding is based on SSDP events it was working. However, relying on SSDP caused many other issues. Therefore, I based the new version on plain network connectivity. Also, I am not sure, if with the OH abstraction on SSDP / UPNP that I could distinguish between the ā€œhelloā€ and ā€œgoodbyeā€ notification. Should really work without it.

So the TV did not properly close the websocket session. The websocket library times out. Which leads to follow up errors, described below.

first case, the websocket client is in a bad state.
second case, binding thinks it is already connecting, therefore does not retry.

Donā€™t have a solution yet. Just thought I share what I found so far.

Thank you for your comments. Let me know if I can help you.

Olli