Logic Machine Forum
LG smart TV - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: LG smart TV (/showthread.php?tid=615)

Pages: 1 2


LG smart TV - Desislav - 13.02.2017

Hello,
Does anybody have a script to control LG smart TV over IP?


RE: LG smart TV - Keitz - 26.12.2017

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


RE: LG smart TV - Thinklight - 14.05.2018

Hi,
anybody was try to control from LUA ?


RE: LG smart TV - Bitver - 14.05.2018

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/showthread.php?tid=1294&highlight=websocket


RE: LG smart TV - ro_ki@tut.by - 13.07.2020

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", "")



RE: LG smart TV - jose_dli - 31.10.2020

thanks a lot!! for your contribution, it works perfect on my system


RE: LG smart TV - AlexLV - 05.11.2020

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


RE: LG smart TV - AlexLV - 06.11.2020

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", "")


RE: LG smart TV - khalil - 22.03.2021

(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,


RE: LG smart TV - admin - 22.03.2021

Correct link: https://forum.logicmachine.net/showthread.php?tid=1294


RE: LG smart TV - khalil - 22.03.2021

(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!'});


RE: LG smart TV - admin - 22.03.2021

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)



RE: LG smart TV - khalil - 22.03.2021

(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


RE: LG smart TV - alexgleyzer - 02.06.2021

Thank you!!! Everything works!!!


RE: LG smart TV - alexgleyzer - 21.06.2021

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


RE: LG smart TV - admin - 22.06.2021

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/8947/activating-wake-on-lan


RE: LG smart TV - alexgleyzer - 23.06.2021

Thank you!!


RE: LG smart TV - khalil - 27.06.2021

(23.06.2021, 16:29)alexgleyzer Wrote: Thank you!!

Hello 
Does it work with LG TVs 

regards,


RE: LG smart TV - admin - 28.06.2021

Yes this is for LG TVs. It's not guaranteed to work for all models though.


RE: LG smart TV - khalil - 28.06.2021

(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?