UNPKG

node-red-contrib-lgtv-with-fullscreen

Version:

Node-RED Nodes to control LG webOS Smart TVs, with browser fullscreen

31 lines (26 loc) 947 B
module.exports = function (RED) { function LgtvBrowserNode(n) { RED.nodes.createNode(this, n); const node = this; this.tv = n.tv; this.passthru = n.passthru; this.tvConn = RED.nodes.getNode(this.tv); if (this.tvConn) { this.tvConn.register(node); this.on('close', done => { node.tvConn.deregister(node, done); }); node.on('input', msg => { if (msg.payload) { node.tvConn.request('ssap://system.launcher/open', { target: msg.payload }); node.tvConn.fullscreen(); } else { node.tvConn.request('ssap://system.launcher/close', { id: 'com.webos.app.browser' }); } }); } else { this.error('No TV Configuration'); } } RED.nodes.registerType('lgtv-browser', LgtvBrowserNode); };