Quick update: I have a solution now! In short: I had to “give in” and use Node to augment Smart Things.
Slightly more detail for now: I’m not quite done yet, so some of this may change, but in general:
- I have a Synology device, so I used the GUI to install Node (note that I actually have Node and Apache both running, which doesn’t seem to be a problem at all!)
- SSH into my Synology and using NPM I installed lgtv2, so literally
npm install lgtv2
- (Obviously) plug my LG TV in with wired Ethernet. (Slightly less obviously) I needed to enable WakeOnLan, which is done implicitly by disabling the power saving mode. This was tricky to find because it seems to be relatively recent that LG changed this workflow and the old docs all refer to an explicit WOL menu that’s no longer there.
- Put this in a text file, I’ll call it
tvcontrol.js
. This is pure JavaScript meant to be executed by Node. Note that I’m using “static DCHP” so my TV’s IP address on my LAN doesn’t change. You’ll need to decide how you want to point at your TV - basically “put the correct LAN IP and ignore any readme instructions you find about lgsmarttv.lan or anything like that.” (those are in the otherlgtv
node package, “v1”, that I’m not using).
var lgtv = require(“lgtv2”)({ url: ‘ws://192.168.1.2:3000’});
lgtv.on(‘connect’, function (err, res) {
lgtv.request(‘ssap://system.launcher/launch’, {id: ‘com.webos.app.browser’, target: ‘http://google.com/#q=smartthings+lgtv’});
lgtv.disconnect();
});
- Execute the script with
node tvcontrol.js
. Note: The first time you do this the TV should ask you if it is ok to pair with the network remote, which you’ll need to manually approve with your existing television hardware remote (e.g. the IR one). Successful pairing should save a kind of keyfile locally that will be automatically detected by lgtv2 so you don’t need to re-pair in the future.
All the magic was in Step 4’s JavaScript. It was a bit hard to figure out how to hand the right request
payload, but now that I’ve got it I’m all good. I’ve run some spot checks and this command forcefully opens the web browser to the URL in question no matter what else the TV was doing - exactly as I wanted!