[PORT] LG Smart TV Discovery 2012+

I have made some additions to the package to better support the WebOS TVs... Including:

  • power off detection (The issue that @natemate discovered... It turns out that the TVs send a final message via a subscription when it starts the power down process... The driver detects it and indicates the power off state. When the power down procedure finishes, the TV then closes the websocket, and the driver then starts the poll process to detect power on)
  • streamlined websocket handing
  • better state processing
  • Channel data processing for Live TV

The new version is available here.

3 Likes

All of those apps are only effective on NetCast model TVs. It is not possible to open any of the hidden menus from a websocket connection.

@cybrmage
Thanks mate for all the work.

I have managed to get into the service menu (both EZ-ADJ and In-Start)
No idea what options to tweak or how to enable IP Control menu in there.
Saw an option for RS232C and enabled it in there. SSID Control is an option, but haven't changed. not sure what it does.
I am connected via Ethernet FYI.

If anyone on the forum has tweaks for the service menu or in-start menu. would welcome.
FYI. You can change a lot of settings in this menu. including region (I have used to get US/UK LG Store Apps installed)

Thank you for this! Going to test this out - maybe I can get rid of my power monitoring plug finally.

Could I bother you into uploading your code to github? Perhaps the community repo or your own? It's a lot easier to import into Hubitat this way and maybe somewhere down the line people could reference your code easily.

edit: Did some testing - power off detection works great, even when turned off manually via remote.

Does the TV also send a message when the power is ON via remote or other means? From my basic understanding, there seems to be a 60s timer in your code to check if the TV responds to ping, and that's what opens the websocket and determines ON state. It would be great if I can get instant on status updates in addition to off. Let me know if there's anything I can do to help test.

1 Like

No, the TV does not send a notification when it is turned on. When the TV is off, the websocket connection is lost. When the TV powers on, there is no link between the TV and the HE, until the driver attempts to open the websocket again.

When the websocket is not open, the driver does appear to reconnect every 60 seconds... but what actually happens is that the driver tries to reconnect the websocket... the default timeout for the websocket connection attempt is 30 seconds... When the connection times out it schedules a retry in 60 seconds...

Now, It MAY be possible to get the equivalent of instant power on detection by increasing the timeout and decreasing the retry time... But I have not tried that yet and do not know how having a large timeout on the websocket connect will affect the normal operation of the HE...

Edit: This method will not work... Initially, the websocket takes 30 seconds to timeout, but after the underlying network code determines that the target device is not available (the "no route to host" failure message), the time from the connect request to failure is reduces to under 4 seconds. I don't think that doing a retry every 4 seconds would be good for the HE.. I could add a parameter to set the connection reset delay... You could then set the delay to a level that you are comfortable with given your unique setup...

Ok.

I have added a parameter to the driver to allow selecting the reconnection delay... Please use it carefully... I have tested it with a 5 second reconnect delay and it does not seem to adversely affect the operation of HE... BUT I do not have a lot of stuff happening with my HE yet... Your results may be different.

The new version is v0.2.5

1 Like

@cybrmage Thank you! This is awesome! I really appreciate your efforts, I've wanted WoL for so long and this worked out of the box just great.

I've removed some debugs, and silenced an error in the driver. This helps keep logs a bit cleaner. Updated driver is here:

4 Likes

Thanks @ekimmagrann, @cybrmage and @asj for sharing your code contributions.

I'm using the most recent version posted at @asj's github. I can't discover my LG 2018 C8 with the app, and I'm not sure why.

The discovery app is logging that it's looking for TVs every couple minutes, but nothing else happens.

My TV is connected to the internet, same LAN and subnet as the HE hub, with a DHCP reservation. The settings on the TV are enabled to allow mobile connections.

I'm also noticing that if i try to use the LG TV mobile app, it can't discover the TV either. However, I am able to cast my windows 10 laptop screen directly to the TV.

Can anyone suggest any troubleshooting steps to nail down the issue? Thanks.

I haven't dug into the discovery code at all yet, so I don't have any good ideas. But if LG's own app doesn't work, I'd start there first.

Go into Settings and make sure remote access is turned on, or what ever they call it. It's not the most obvious. Then when you try and connect it should pop up a dialog on the bottom asking you to allow the connection.

So I was able to get the LG app working at least. I noticed by turning the TV off and back on, that got it to show up on the LG app discovery screen.

That doesn’t seem to be helping with the HE discovery process though...

Thanks for putting this out there for the Hubitat community! Your Driver and Application successfully turns on and off my LG 2018 OLED B8 series TV.

Thank you for this driver, I can change the volume, turn the power OFF but I can't turn it back ON.

I have a LG webOS UH8500.

Here is what I see:

State Variables

  • sequenceNumber : 4
  • channelData :
  • currentInput :
  • lastPower : false
  • channel :
  • reconnectDelay : 1
  • lastChannelDesc :
  • webSocket : open
  • inputList : []
  • lastChannel :
  • reconnectPending : false
  • serviceList : []
  • channelName :
  • channelDesc :
  • power : true
  • lastInput :
  • pairFailCount : 0
  • paired : false

Are you using ethernet or wifi?

Wifi DHCP but reserved address.

@yannick00000 I've seen numerous reports that the LG TVs don't do WoWLAN (wireless wake on lan). Sorry.

Ok, I will see if I can get a Ethernet cable to the TV and retest. Thank's for you help

Hi, today I connected my LG webOS UH8500 to Ethernet. Again, most functions work, and now the TV doesn't ask me to reconnect every 5 minutes. It's always connected. But again, I can turn it OFF but can't turn it back ON.

Any ideas on what to look for ?

Thanks !

Yannick

I just did some more testing and the device does report going back to OFF state after sending the ON command (30 seconds after sending the OFF) so the communication is still there even of the TV wont turn back ON.

Here is some logs:

dev:12922019-10-08 13:29:56.776 debugScheduling reconnect in 60 seconds

dev:12922019-10-08 13:29:56.773 infowebsocket reconnect - delay = 60

dev:12922019-10-08 13:29:56.769 debugsendPowerEvent: sending state.power = OFF event

dev:12922019-10-08 13:29:56.761 debugfailure: No route/connect timeout/no pong for websocket protocol

dev:12922019-10-08 13:29:56.744 debugsetPaired: setting state.paired = FALSE

dev:12922019-10-08 13:29:56.741 debugfailure message from web socket failure: No route to host (Host unreachable)

dev:12922019-10-08 13:29:56.737 debugwebSocketStatus: State: [initialize] Reported Status: [failure: No route to host (Host unreachable)]

dev:12922019-10-08 13:29:53.583 debugConnecting websocket to: "ws://192.168.102.96:3000/"

dev:12922019-10-08 13:29:53.516 debugsetPower: setting state.power = OFF

dev:12922019-10-08 13:29:53.513 debugsetPaired: setting state.paired = FALSE

dev:12922019-10-08 13:29:53.504 debugLG Smart TV Driver - initialize - settings:['televisionIp':'192.168.102.96', 'debug':true, 'descriptionText':true, 'channelDetail':false, 'retryDelay':'60', 'televisionType':'WEBOS', 'televisionMac':'c8:08:e9:bb:65:8b', 'pairingKey':'5b4bf895abae4380b6c5a180f514adba']

dev:12922019-10-08 13:29:53.498 debugLG Smart TV Driver - initialize - ip: 192.168.102.96 mac: c8:08:e9:bb:65:8b type: WEBOS key: 5b4bf895abae4380b6c5a180f514adba debug: true logText: true

dev:2262019-10-08 13:29:16.582 infoMS Car Port: motion is active

dev:2262019-10-08 13:29:16.427 infoMS Car Port: motion is active

dev:12922019-10-08 13:28:57.001 infoSending Magic Packet to: wake on lan c8:08:e9:bb:65:8b

dev:12922019-10-08 13:28:56.997 debugSending Magic Packet to: c8:08:e9:bb:65:8b

dev:12922019-10-08 13:28:56.993 debugsendPowerEvent: sending state.power = ON state change event

dev:12922019-10-08 13:28:56.988 debugExecuting 'Power On'

dev:12922019-10-08 13:28:53.458 debugScheduling reconnect in 60 seconds

dev:12922019-10-08 13:28:53.454 infowebsocket reconnect - delay = 60

dev:12922019-10-08 13:28:53.451 debugScheduling reconnect in 60 seconds

dev:12922019-10-08 13:28:53.448 infowebsocket reconnect - delay = 60

dev:12922019-10-08 13:28:53.446 debugsendPowerEvent: sending state.power = OFF event

dev:12922019-10-08 13:28:53.443 debugsendPowerEvent: sending state.power = OFF event

dev:12922019-10-08 13:28:53.440 debugfailure: No route/connect timeout/no pong for websocket protocol

dev:12922019-10-08 13:28:53.437 debugfailure: No route/connect timeout/no pong for websocket protocol

dev:12922019-10-08 13:28:53.434 debugsetPaired: setting state.paired = FALSE

dev:12922019-10-08 13:28:53.431 debugsetPaired: setting state.paired = FALSE

dev:12922019-10-08 13:28:53.417 debugfailure message from web socket failure: No route to host (Host unreachable)

dev:12922019-10-08 13:28:53.414 debugfailure message from web socket failure: No route to host (Host unreachable)

dev:12922019-10-08 13:28:53.410 debugwebSocketStatus: State: [initialize] Reported Status: [failure: No route to host (Host unreachable)]

dev:12922019-10-08 13:28:53.406 debugwebSocketStatus: State: [initialize] Reported Status: [failure: No route to host (Host unreachable)]

dev:12922019-10-08 13:28:51.316 debugConnecting websocket to: "ws://192.168.102.96:3000/"

dev:12922019-10-08 13:28:51.274 debugsetPower: setting state.power = OFF

dev:12922019-10-08 13:28:51.271 debugsetPaired: setting state.paired = FALSE

dev:12922019-10-08 13:28:51.255 debugLG Smart TV Driver - initialize - settings:['televisionIp':'192.168.102.96', 'debug':true, 'descriptionText':true, 'channelDetail':false, 'retryDelay':'60', 'televisionType':'WEBOS', 'televisionMac':'c8:08:e9:bb:65:8b', 'pairingKey':'5b4bf895abae4380b6c5a180f514adba']

dev:12922019-10-08 13:28:51.249 debugLG Smart TV Driver - initialize - ip: 192.168.102.96 mac: c8:08:e9:bb:65:8b type: WEBOS key: 5b4bf895abae4380b6c5a180f514adba debug: true logText: true

dev:12922019-10-08 13:28:50.237 debugConnecting websocket to: "ws://192.168.102.96:3000/"

dev:12922019-10-08 13:28:50.171 debugsetPower: setting state.power = OFF

dev:12922019-10-08 13:28:50.168 debugsetPaired: setting state.paired = FALSE

dev:12922019-10-08 13:28:50.151 debugLG Smart TV Driver - initialize - settings:['televisionIp':'192.168.102.96', 'debug':true, 'descriptionText':true, 'channelDetail':false, 'retryDelay':'60', 'televisionType':'WEBOS', 'televisionMac':'c8:08:e9:bb:65:8b', 'pairingKey':'5b4bf895abae4380b6c5a180f514adba']

Does turning it on via hardwired Ethernet work via the LG Smartify app?

Download the Hubitat app