[PORT] LG Smart TV Discovery 2012+

The driver will detect a "power off" in one of two ways.... You explicitly send a "power off" command... or the websocket closes (which happens when the TV turns off). It likewise determines power on in one of two ways... You explicitly send a "power on" command, or the websocket is able to reconnect to the TV (a reconnect is attempted every 60 seconds when the websocket is disconnected).

If the TV keeps the network connection active when it is "turned off", I don't know how it would be possible to determine that it is in standby mode... Unless the OLED TV's return extra data that the UHD and SUHD models do not...

To find out... Have the TV on... go to the HE log page... clear the old logs, then turn off the TV with the remote... wait about 60 seconds and them grab the logs and post them so I can see if there is any extra data available.

Hi Mate,
I have the "LG Connect Apps" option under Settings>Network and have enabled it.

What would I need to do from here to enable power on?

FYI: TV does not have the "Mobile TV On" option under Settings>General

Cheers
G

The "LG Connect Apps" option enables the websocket server... The "Mobile TV On" option enabled wake-on-lan.

If you do not have the "Mobile TV On", you can not enable wake-on-lan, and you will need to use some other method to power on the TV.

The only other possibility is the "Secret Network Menu" that was present on some WebOS models...
Set the TV to LiveTV... Using the TV Remote, press and HOLD the setup button until the channel banner appears in the upper left of the screen, then press "8", "2", "8" then "OK". If your set has the secret menu, it will be displayed and there MAY be an option to enable wake-on-lan. This menu is not present on models with the "Mobile TV On" option..

828 doesn't do anything. 1105 gets me into hotel menu. But 828 doesn't get me anywhere.

My sets do not have the secret network menu either... And the hotel menu code, on mine, brings up a "Public Displays" menu... Which has a section for "IP Control" which then has an option to enable wake-on-lan...

What options does the hotel menu give you?

Another possibility is:
Open the full settings menu. Move the cursor to highlight "Network". enter 82888. On some models this brings up the "IP Control" menu.

If there is no "Wake On Lan" or "Mobile TV On" or "Wake over WiFi" option, your TV does not support wake-on-lan, and you will need to use some other option...

Looking at some of the options in the "Public Display"/"Hotel" menu... There is a "Power On Default" menu item, that lets you set the TV to automatically turn on (and optionally select a specific input) after a power failure... If you are unable to use a chromwcast or IP to IR device to power on your TV, then you could enable this option, plug the TV into a smart outlet (Wifi or Zigbee or ZWave) and use rules to cycle the power...

Can't get into service menu or IP control menu.

Can you add a command to the App for EZ_ADJUST
Doing some research, there is Android apps out there that can send commands via IP to access service menu

Please take a look at your code, you have written some kind of loop that closes and reopens the connection every 60 seconds.

Thank for catching that...

I have fixed the issue... New version is available here

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

2 Likes

@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.