Advertisement
demoss

LGTV

Mar 18th, 2023 (edited)
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { LGTV, Inputs, Keys } from 'lgtv-ip-control';
  2. import * as readline from 'node:readline/promises';
  3. import { stdin as input, stdout as output } from 'node:process';
  4. const rl = readline.createInterface({ input, output });
  5. const tv = new LGTV('10.0.255.183', '1a:2b:3c:4d:5e:6f','MDLLCIDN');
  6.    
  7.         function sender(){
  8.               try{
  9. tv.connect()
  10.   .then(async () => {
  11.     async function comm () {
  12.         const kk = await rl.question('enter command: ');
  13.         if (kk.includes('hdmi') | kk.includes('dtv')){
  14.         await tv.setInput(Inputs[kk]);
  15.         console.log(Inputs[kk]);
  16.         }
  17.         else{
  18.         await tv.sendKey(Keys[kk]);
  19.         console.log(Keys[kk]);
  20.         }
  21.     }
  22.     await comm();
  23.     })
  24. }
  25.         catch(e){
  26.       print(e.name);
  27.       tv.disconnect();
  28. }
  29.         }
  30. sender();
Tags: js
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement