This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

LG smart TV
#1
Hello,
Does anybody have a script to control LG smart TV over IP?
Reply
#2
(13.02.2017, 16:53)Desislav Wrote: Hello,
Does anybody have a script to control LG smart TV over IP?

Hello,

Yes is it possible to change this python script to lua ? see : https://github.com/ubaransel/lgcommander
This is a script to control a LG smart TV.
Reply
#3
Hi,
anybody was try to control from LUA ?
Reply
#4
Here is websocket script. I've tried, but something did wrong. If anyone could use it and make LG TV control, it would be great.
https://forum.logicmachine.net/showthrea...=websocket
Reply
#5
Attached you can find the library to control LG TV with Web OS. 
It uses Lua websocket library from here https://github.com/lipp/lua-websockets. Websocket library is also available in this forum.
Just change the name of the library to yours in the coding ('user.websocket_client_sync')

It was inspired by Node.JS module https://github.com/hobbyquaker/lgtv2, you can also find a list of commands and configuration instructions there.

Coding is published as is , errors are possible Smile

The following command will turn Off the LG TV . 2 constants below are the IP address of the LG TV and the KNX group address to store the handshake key.
Code:
lg_execute_command(LGTV65_IP, LGTV65_KEY, "", "request", "ssap://system/turnOff", "")

Attached Files
.lua   lgtv.lua (Size: 7.41 KB / Downloads: 118)
Reply
#6
thanks a lot!! for your contribution, it works perfect on my system
Reply
#7
Hi,

what it could be? See such errors in log:

* arg: 1
* string: Connection close result:
* arg: 2
* bool: true
* arg: 3
* number: 1000
* arg: 4
* string:


* string: {"type":"error","id":"4102853981","error":"401 insufficient permissions (not registered)","payload":{}}

* string: Connection timeout


Alex
Reply
#8
Finally all is OK. When I tried send command (from other room) TV showed info should we accept new connection? (This active some seconds..). Just today found out this Smile With TV remote control we need accept request and all working Smile

A little instruction how to start TV work with LM (Thanks to Jose_dli user):

You have to create 3 things, the first is the object type "250 byte string" without any value stored in it. It is for store the handshake/key in the first connection, in my system '32/7/0'

Second load in Scripting-->User libraries-->add new library the one that you can find in https://forum.logicmachine.net/showthrea...=websocket. before load library rename it from websocket.lua to websocket_client_sync.lua

And third, copy-paste script "lgtv.lua" at the end of Scripting-->common functions

I execute lg_execute_command("192.168.0.20", '32/7/0', "", "request", "ssap://system/turnOff, "") instead of lg_execute_command(LGTV65_IP, LGTV65_KEY, "", "request", "ssap://system/turnOff", "")
Reply
#9
(06.11.2020, 21:29)AlexLV Wrote: Finally all is OK. When I tried send command (from other room) TV showed info should we accept new connection? (This active some seconds..). Just today found out this Smile With TV remote control we need accept request and all working Smile

A little instruction how to start TV work with LM (Thanks to Jose_dli user):

You have to create 3 things, the first is the object type "250 byte string" without any value stored in it. It is for store the handshake/key in the first connection, in my system '32/7/0'

Second load in Scripting-->User libraries-->add new library the one that you can find in https://forum.logicmachine.net/showthrea...=websocket. before load library rename it from websocket.lua  to websocket_client_sync.lua

And third, copy-paste script "lgtv.lua" at the end of Scripting-->common functions

I execute lg_execute_command("192.168.0.20", '32/7/0', "", "request", "ssap://system/turnOff, "") instead of lg_execute_command(LGTV65_IP, LGTV65_KEY, "", "request", "ssap://system/turnOff", "")

this link didn't work: https://forum.logicmachine.net/showthrea...=websocket.
could you post a working link or the LUA user script for the websoket
@ admin

regards,
Best Regards,
Reply
#10
Correct link: https://forum.logicmachine.net/showthread.php?tid=1294
Reply
#11
(13.07.2020, 17:54)ro_ki@tut.by Wrote: Attached you can find the library to control LG TV with Web OS. 
It uses Lua websocket library from here https://github.com/lipp/lua-websockets. Websocket library is also available in this forum.
Just change the name of the library to yours in the coding ('user.websocket_client_sync')

It was inspired by Node.JS module https://github.com/hobbyquaker/lgtv2, you can also find a list of commands and configuration instructions there.

Coding is published as is , errors are possible Smile

The following command will turn Off the LG TV . 2 constants below are the IP address of the LG TV and the KNX group address to store the handshake key.
Code:
lg_execute_command(LGTV65_IP, LGTV65_KEY, "", "request", "ssap://system/turnOff", "")

how to set the payload commands 
like If I want to change the volume or send a notification:
Like this one from GitHub
request('ssap://system.notifications/createToast', {message: 'Hello World!'});
Best Regards,
Reply
#12
You need to encode the payload using JSON:
Code:
payload = json.encode({ message = "hello" })
lg_execute_command(LGTV65_IP, LGTV65_KEY, "", "request", "ssap://system.notifications/createToast", payload)
Reply
#13
(22.03.2021, 12:17)admin Wrote: You need to encode the payload using JSON:
Code:
payload = json.encode({ message = "hello" })
lg_execute_command(LGTV65_IP, LGTV65_KEY, "", "request", "ssap://system.notifications/createToast", payload)

great 
thanks Admin
Best Regards,
Reply
#14
Thank you!!! Everything works!!!
Reply
#15
Hello again!
Is there a way to turn TV on?? I believe TV keeps LAN connection open, because Android application can turn it on.
Regards, Alex
Reply
#16
You can try sending Wake on LAN packet to it. See this: https://forum.logicmachine.net/showthread.php?tid=849
Some additional settings on the TV side might be required: https://lgcommunity.us.com/discussion/89...ake-on-lan
Reply
#17
Thank you!!
Reply
#18
(23.06.2021, 16:29)alexgleyzer Wrote: Thank you!!

Hello 
Does it work with LG TVs 

regards,
Best Regards,
Reply
#19
Yes this is for LG TVs. It's not guaranteed to work for all models though.
Reply
#20
(28.06.2021, 06:37)admin Wrote: Yes this is for LG TVs. It's not guaranteed to work for all models though.

thank you, admin
Is there a way to know which modules are supported?
I have this setting on my tv https://lgcommunity.us.com/discussion/89...ake-on-lan ,so does this mean it's supported?
Best Regards,
Reply


Forum Jump: