LG Smart TV 2012+ Integration

Just with a LAN cable, no wifi right?

WoW ! exquisite.
Amazing is what you’re building. I can’t just wait to use your application on my Smart Tv. I have been using Kodi on smart tv. it would be really nice to use this app to control it.
Thanks in advance.

I can turn off the tv with this app but can not turn on. I found a fairly easy way to turn on the tv with chrome cast and google home. I changed the tv name in google home as TV and smart things recognize the same tv as LG smart tv. I can turn on the tv asking to play something on youtube or netflix. I can turn off the tv by asking turn off lg smart tv…

I am having the discovery issue as well. Logs below. It seems to find the TV, but it never shows up on the SmartThings app. Model is a 49UJ6300. I assume that running the SmartApp is the first step. I also tried creating the device manually, but that doesn’t seem to be correct.

4530646d-ce94-4152-82ca-b167162596cf 5:48:57 PM: debug hub: 5754332e-1721-4d99-8969-31a801ae8583
4530646d-ce94-4152-82ca-b167162596cf 5:48:57 PM: debug upnp: [devicetype:04, mac:00044B8394CF, ip:C0A80211, ssdpPath:/dev/f6fc3bd7-9835-e4f8-0000-000038b27980/desc.xml, ssdpUSN:uuid:f6fc3bd7-9835-e4f8-0000-000038b27980::urn:schemas-upnp-org:device:MediaRenderer:1, ssdpTerm:urn:schemas-upnp-org:device:MediaRenderer:1]
4530646d-ce94-4152-82ca-b167162596cf 5:48:57 PM: debug Device Location Event: devicetype:04, mac:00044B8394CF, networkAddress:C0A80211, deviceAddress:81D1, stringCount:04, ssdpPath:/dev/f6fc3bd7-9835-e4f8-0000-000038b27980/desc.xml, ssdpUSN:uuid:f6fc3bd7-9835-e4f8-0000-000038b27980::urn:schemas-upnp-org:device:MediaRenderer:1, ssdpTerm:urn:schemas-upnp-org:device:MediaRenderer:1, ssdpNTS:
4530646d-ce94-4152-82ca-b167162596cf 5:48:42 PM: debug hub: 5754332e-1721-4d99-8969-31a801ae8583
4530646d-ce94-4152-82ca-b167162596cf 5:48:42 PM: debug upnp: [devicetype:04, mac:00044B8394CF, ip:C0A80211, ssdpPath:/dev/f6fc3bd7-9835-e4f8-0000-000038b27980/desc.xml, ssdpUSN:uuid:f6fc3bd7-9835-e4f8-0000-000038b27980::urn:schemas-upnp-org:device:MediaRenderer:1, ssdpTerm:urn:schemas-upnp-org:device:MediaRenderer:1]
4530646d-ce94-4152-82ca-b167162596cf 5:48:42 PM: debug Device Location Event: devicetype:04, mac:00044B8394CF, networkAddress:C0A80211, deviceAddress:81D1, stringCount:04, ssdpPath:/dev/f6fc3bd7-9835-e4f8-0000-000038b27980/desc.xml, ssdpUSN:uuid:f6fc3bd7-9835-e4f8-0000-000038b27980::urn:schemas-upnp-org:device:MediaRenderer:1, ssdpTerm:urn:schemas-upnp-org:device:MediaRenderer:1, ssdpNTS:

Doesn’t seem to pickup my TV. Any simple way to see if a TV is on?

Has anyone had any luck with this recently? I’ve had the same issue with the smartapp not discovering the TV (LG OLEDB8). Logs show mac address etc.

So I did a little research on this and I think I may have discovered why some TVs are not being discovered. Looking at the LG Developer documentation, I found that there are specific headers required in the M-SEARCH discovery request in order for the TV to respond (See page 8/9 here http://webostv.developer.lge.com/application/files/1214/7919/6747/NetCast_-_UDAP.pdf).

  1. HOST
  2. MAN
  3. MX
  4. ST
  5. USER-AGENT*

After running a packet capture, I found that the M-SEARCH request generated by SmartThings does not include the “USER-AGENT” header (See capture below):

Received 4/25/2019 at 10:56:24 AM (8)

M-SEARCH * HTTP/1.1
MX: 4
MAN: "ssdp:discover"
HOST:239.255.255.250:1900
ST: urn:schemas-udap:service:netrcu:1

I am not entirely sure why the discovery works for some but not others but I believe the culprit could be those of us who may be on later firmware revisions. :man_shrugging:

To get around the discovery all together, I went ahead and manually created the device specifying the device handler “LG Smart TV 2012+”.

Example:

Once the device was created, using Postman, I generated a HTTP POST request to the TV’s API to bring up the pairing key window on the TV. Make sure the TV is ON:

Example:


Request:

POST /roap/api/auth HTTP/1.1
Host: 10.0.3.237:8080
Content-Type: application/atom+xml
Cache-Control: no-cache
Postman-Token: d45e3994-c74a-228d-70ab-20d0da66e270

<?xml version=\"1.0\" encoding=\"utf-8\"?><auth><type>AuthKeyReq</type></auth>

At this point, you should see the pairing code displayed on the TV. Go back to the IDE and in the device settings, edit the preference section with the IP address of the TV and the pairing code.

Example:

You can now control the device via the SmartThings app.

Hopefully this helps anyone struggling with the discovery issue!

Can someone explain how to do this?

1 Like

For LG Dryer, there seems to be a lag. I shut off my dryer but the Device in Smartthings takes a very long time to show an event for Off. It remains on. Similarly the other way around – when turned off and then turned on it takes a very long time to show on. (?)

It actually never changes state at all unless I restart the Docker container?

Hi, I was able to follow most of this post and ur directions except for the postman part to get the pairing key. I tried it exactly as u said…assuming “HOST” is where I put my TV’s IP followed by the port 8080? Not entirely sure if I did it right…but it returns nothing. It fails to prompt my TV to display the pairing key. Plz help…this is my first try at doing this. I have an LG OLED C7 TV.

Hi Sam,

You mentioned in the comment that you have configured to allow other apps to see it as a switch. This isnt the case for Webcore. Nothing is present when you try to add the Device under the avaliable devices list.

I have the Smartapp working but would be great to allow the TV (even just the Off Switch) to be included in Webcore Pistons.

Thanks

Hi

I’m trying to pair the app with the TV. The app requests the pin and the pin is displayed on the TV but there is nowhere I can enter the pin on the app all I can select is done.

Any ideas this is in the new smartthings app.

Thanks
Tony

@Tony_Kerwin ,
As I see that nobody answers you, I tell you that have modified the samrtapp and the DTH and although it does not work well, it still does not show where to write the TV key, but the device controller can be created and it works.
As they say in previous posts, it is only valid to “turn off the TV” and this is for the reason that when these TVs are OFF, the TV network does not work and therefore it is impossible to send the “power on” command.
The other functions do not work because the new smartthings app only recognizes the “switch tile” and therefore other commands can’t be sent.
If you are still interested, I will give you the links

Hi.
Could you please send link to me too?

Modified app & DTH with links in post number 48

My TV is older model and is impossible turn on with wake Up on lan command, but if your TV is new webos model, could turn on as say this post.

@Alexander_vm & @Tony_Kerwin,
Fixed problem to find TV and write TV key in smart app.
I delete the previous links and put the news.

INSTALL STEPS :

  • -Create and publish samrtapp and Controller DTH in IDE.
  • -Open The App, click on “Discovery” to found TV.
  • -If Show ‘Select LG TV(0 found)’ click next until ‘Select LG TV(1 found)’, then ‘Tap to set’ to select IP TV"
  • -Select the TV app found, just find 1. click on “done” the key code will appears on the TV screen, take note of it.
  • -(Every 15 seconds refresch TV found and clean the previous selection)
  • -Click on “TV Key”, write the copied code TV key and click done.
  • -NOTE: Device controller only works to turn off the TV. When these LG TVs are OFF the network does not work and therefore it is impossible to turn them ON
  • IMPORTANT: You must be configure in your router Fix IP for your TV or TV IP will change even 12 Hours normally

I tried following the instructions in your post but I get stuck on:

-If Show ‘Select LG TV(0 found)’ click next until ‘Select LG TV(1 found)’, then ‘Tap to set’ to select IP TV"

When I click next it takes me back to the main screen which shows Discovery and TV Key. Should I keep going back into Discovery and then clicking Next? Also, how long should I wait while it is searching before I click Next?

@alexcapone,

You better use this other app and DTH. It works better and has more functions, mute, power save screen off and refresh the status every 5 minutes.

Important, these LG TVs if you turn them off with the remote control or from the app, you can only turn them on again with the remote control.
If you just want to turn the TV on and off, you can put a smart plug, zigbee or zwave for the TV. As the TV remembers the last state, you can always turn it off and on with the smart plug, which is almost the same as the app does.