hobbyquaker / lgtv2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from msloth/lgtv.js
Control LG WebOS TV using node.js :tv:
License: MIT License
This project forked from msloth/lgtv.js
Control LG WebOS TV using node.js :tv:
License: MIT License
Do you have an example using DIAL?
Is it possible to send a command to turn the TV screen off while leaving the music playing. There is a option on the TV to turn screen off while keeping the TV running. However, it is buried in menus and it is much more convenient to trigger it through node.
Hey, I have 2 questions about usage of this project.
In repo README, you have asked to configure TV settings
You need to allow "LG Connect Apps" on your TV - see http://www.lg.com/uk/support/product-help/CT00008334-1437131798537-others
But the link does not open specific issue solution, it just lands on main support page.
I was able to connect to the TV using your repo.
Now the issues is : I have to allow pairing from TV every time TV starts. So, is there a way using which, the device gets paired once and does not need to be allowed every time?
Please guide me.
Thanks!
In January 2023, LG disabled http access? Now must use secure https connections only? So wss: and port 3001 only?
events.js:174
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND lgwebostv lgwebostv:8000
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
Emitted 'error' event at:
at WebSocketClient. (/var/www/html/lgtv2/node_modules/lgtv2/index.js:82:18)
at WebSocketClient.emit (events.js:189:13)
at ClientRequest.handleRequestError (/var/www/html/lgtv2/node_modules/websocket/lib/WebSocketClient.js:227:14)
at ClientRequest.emit (events.js:189:13)
at TLSSocket.socketErrorListener (_http_client.js:392:9)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
When I connect to my LGTV from my laptop (Windows 10) on WiFi, it asks me once to allow pairing, and then the API works. I can restart node over and over and I'm not asked to pair again.
When I connect from a machine on ethernet (Ubuntu), I'm asked to pair (by the TV) every time I restart node.
Any ideas?
Hi,
I have LG 55LH600T (web os 3.0 based) TV. In my TV , multi-view app is not enabled.
How can I enable / install multi-view app and use multi-view feature using lgtv2?
you have implemented 3DOn and 3DOff.
Does 3DOn just take whatever state you had left 3D with before, such as left/Right or Top/Bottom?
I have successfully managed to get any app id (Sky, Netflix, Prime, Disney+) with:
lgtv.request('ssap://com.webos.applicationManager/listApps', function(err,res) { console.log(res); });
Is there a way to retrieve information about the current stream, such as title or runtime, from any of the above apps?
I'm receiving an LG CX 48" soon and would like to control some things on it with this project. However, I tried googling for a list of commands and just can't seem to find one that is any more comprehensive.
Is there a full list of supported commands somewhere or do I have to send button inputs in sequence if I want to for example change picture preset or toggle OLED motion?
Hello, i found on your site how to switch to Netflix. But what is the command for Prime?
Thx
Hi, curious if anyone with an LG TV is observing very long delays (10-15s) before the LG TV websocket is available for connection after the TV is powered on? I have an 2017 OLED65E7 webos3.7
I have a written a very small bash script using netcat to detect when ws is ready for connection and will stop when netcat connects to LG ws. I've executed it many times, and my LG ws is only ready after 10-15sec.
wakeonlan [LG mac addr];./checkport.sh
checkport.sh
#!/bin/bash
time=0;
result=1;
while [ $result -ne 0 ]; do
nc -z -w1 [LG IP] 3000;if [ $? -eq 0 ]; then
let result=0;
fiecho Port: $? Time: $time;
sleep 1;
((time++));done
Thanks for an insight/info !
Hallo @hobbyquaker gibt es auch die Möglichkeit das man z.B. direkt einen Befehl hat der den Energiesparmodus einschaltet oder z.b. Youtube öffnet?
hello,
i try to use your module but when i try exemple (with good ip) i take systematically an error connexion refused.
could you help me ?
best regards
lgtv2 can no longer connect to the LG TV on port 3000 after a recent firmware upgrade of the TVs webOS.
Also the menu entry "LG Connect Apps" is no longer present :(
Can anyone confirm this?
webOS TV NANO916NA
Hello, I would like to see the full documentation of the API. Where can I find it? Thank you!
I see that when launching a TV app you can pass a contentId
but I have no idea how to read that value inside the TV app itself. Anyone have any of how to do that?
Hi,
Create project! I would like to use switchInput to change the hdmi, but can't seem to find the right command. Could you please give an example on how to use this command? I've found some other sources that use the same api, but no official documentation. Do you have a link for that as well?
Thanks!
Roy
I am developing a web hosted app. I need to open an internet page inside that app in a way that I see the cursor and I can move it around the page and click on buttons, using the regular remote control.
I don't see a way to enable the cursor and make it move as I click on the remote arrows, as it does in the internet browser that comes with the tv.
So, I need one of two things:
thanks
Hi,
I finally found solution to change e.g. picture presets. Please see my last comment at:
https://community.home-assistant.io/t/lg-webos-change-picture-setting-mode-with-scripts/262915
Maybe this could be implemented into lgtv2 as well?
Thanks and regards,
Helge
hi guys i've been trying to get the YouTube app to open from the webostv.command service for two days. do you know what his 'id' is?
I can open Netflix but not YouTube from home assistant. Thank you all
Does this library have a way to send the "screen mute" command?
I see that requests are sent with a uri
and payload
as per:
Lines 186 to 188 in d58f870
I'm trying to make a change to homebridge-webos
(which uses this library) to turn off the screen only (different than powering off the tv). This is useful to listen to music while the display is off.
I've managed to connect to my TV over IP with Telnet and sent the command SCREEN_MUTE screenmuteon
which keeps the TV on but turns off the screen. There's also a menu option under power settings called "screen off" that I think is doing the same thing.
In homebridge-webos
there is a list of URIs in the form ssap://system/turnOff
:
Is there documentation on all of the URIs? There may be a command to send SCREEN_MUTE
but I don't know what the URI or parameters would be. Any pointers would be helpful.
I'm triying to use Netflix with contentId (so I can directly watch a show) but with no luck at the present time. Has anyone been able to do it? I'm using ConnectSDK as doc of the API call.
I have a question:
Would it be possible to control energy saving mode (Off, Low, Mid, High, Screen off) in a LG TV (SJ8000), running WebOS 3.7.0?
Thanks for your clarification.
It seem as though when an eArc sound bar is connected to the tv I'm unable to control its volume, aside from mute.
When the sound bar is not connected though I'm able to control as expected.
If you disconnect the LG TV from the power supply and then switch it on again, there is a small time window during the boot-up sequence where a TCP connection can be established. Approx. 7 seconds. If the LGTV2 client establishes the connection to the LG TV exactly during this time, the client hangs forever and blocks any further processes.
Do you have an idea or a workaround to prevent this?
You can test it by pinging the TV during boot-up. If the server responds, try to establish a connection with your LGTV2 client.
Important: Before disconnecting the LG TV from the power supply, switch off the TV with the remote control and wait 10 minutes until the pixel cleaning process has been completed. This process runs in the background after switching off the TV.
(Windows ping)
c:\>ping 192.168.1.70 -t
Pinging 192.168.1.70 with 32 bytes of data:
Reply from 192.168.1.10: Destination host unreachable. <--- Boot up LGTV
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.70: bytes=32 time=5ms TTL=63 <--- Connect here
Reply from 192.168.1.70: bytes=32 time=4ms TTL=63
Reply from 192.168.1.70: bytes=32 time=5ms TTL=63
Reply from 192.168.1.70: bytes=32 time=5ms TTL=63
Reply from 192.168.1.70: bytes=32 time=5ms TTL=63
Reply from 192.168.1.70: bytes=32 time=5ms TTL=63
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.10: Destination host unreachable.
Reply from 192.168.1.10: Destination host unreachable.
Hi there,
I have an issue running this on my Synology NAS. Wondering if you could help me solve the problem.
When I run my code locally, for example;
var lgtv = require('lgtv2')({
url: 'ws://192.168.178.31:3000'
});
lgtv.on('error', function(err) {
console.log(err);
});
lgtv.on('connect', function() {
console.log('connected');
lgtv.request('ssap://system/turnOff', function(err, res) {
lgtv.disconnect();
});
});
It run's fine. However, the same code, deployed to my Synology NAS, results in an error.
TypeError: Arguments to path.join must be strings
at path.js:360:15
at Array.filter (native)
at exports.join (path.js:358:36)
at module.exports (/volume1/web/NodeJS/node_modules/persist-path/index.js:19:22)
at new LGTV (/volume1/web/NodeJS/node_modules/lgtv2/index.js:47:16)
at LGTV (/volume1/web/NodeJS/node_modules/lgtv2/index.js:38:16)
at Object.module.exports.setNetflix (/volume1/web/NodeJS/controllers/tv.js:50:36)
at /volume1/web/NodeJS/routes/routes.js:43:12
at Layer.handle [as handle_request] (/volume1/web/NodeJS/node_modules/express/lib/router/layer.js:95:5)
at next (/volume1/web/NodeJS/node_modules/express/lib/router/route.js:137:13)
The only actual difference I can spot is the NPM version, which is v10.14.1 locally and v0.10.48 on my NAS. Is there any way to bypass this problem and get this working?
Is there a turn on feature?
I can’t connect to my LG tv.
Scanning the opened ports, it seems that the 3000 is closed,
And there is no open port for the WebSocket
Hi,
There is any way to get to developer mode/service mode?
I want to change region
Hi, is there a way to receive the pause status of the tv? for example if the viewer has put the netflix, youtube or plex in pause?
Everything was running fine with WebOS 04.70.35.
Start Browser, open a Website and Switch TV off (see ct "Smart-TV eingespannt").
But my TV made an update to 04.70.50. After that TV is asking at each command YES or NO. I have to confirm this by remote control. LG said it is not possible to restore the old firmware.
I think the pairing function is changed in new firmware.
Do anyone help?
If you turn your TV off with the remote and then send the system/turnOff command within the first minute or so, the TV switches back on.
Seems like the LAN port is still accepting connections at that point.
This won't happen if you wait a bit longer. Then a WOL is needed to switch on the TV.
This issue is in a way related to #12
Any idea on how to prevent this?
When you send a "ssap://com.webos.applicationManager/listApps" request to TV, it gives you an array of all apps which contains URLs of icons too. But what is very interesting to me is that none of these links work! They are all dead links.
I tried to sniff into my phone's LG TV Plus traffic to see how it gets app icons from TV, but no luck!
Can someone help me with this?
Thanks.
Edit: Sorry, the solution was to use "listLaunchPoints" instead of "listApps".
i would like to pair using a pin code that is shown in a popup instead of needing to click yes to the popup
This does not work!
addr="10.42.0.235";
lgtv=require("lgtv2")({url: 'ws://' + addr + ':3000'});
lgtv.on('connect', function () {
console.log('connected');
lgtv.request('ssap://audio/setVolume','{"volume": 0}', function (err, res) {
console.log(res,err);
lgtv.disconnect();
process.exit(1);
});
});
This works:
addr="lgtv"; //lgtv = 10.42.0.235 in /etc/hosts
lgtv=require("lgtv2")({url: 'ws://' + addr + ':3000'});
lgtv.on('connect', function () {
console.log('connected');
lgtv.request('ssap://audio/setVolume','{"volume": 0}', function (err, res) {
console.log(res,err);
lgtv.disconnect();
process.exit(1);
});
});
Just wondering if you know of a good way to check this? Might be a good feature to add.
I've tried various endpoints through the websocket but it responds happily to them even when the TV is off. I also tried sending ICMP packets to see if it would reject them when off but no luck.
Any ideas?
Hello.
I've successfully managed to connect to my Web OS TV and I can open the web browser. Is it possible to open the web browser on a specific website?
Thanks in advance
In that.saveKey(), you call writeFile() without a callback. Node complains about it.
Maybe you want to call writeFileSync() ?
Or provide a default cb that does nothing.
Cheers
I think it's on line 140.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.