Last active
April 10, 2023 17:06
-
-
Save bekharsky/80fce4263304eedcec7a46045b1a0ebd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocket = require('ws'); | |
const tvIP = '192.168.3.6'; | |
const ws = new WebSocket(`wss://${tvIP}:8002/api/v2/channels/samsung.remote.control`, { rejectUnauthorized: false }); | |
ws.onopen = () => console.log('opened.'); | |
ws.onclose = () => console.log('closed.'); | |
ws.onmessage = message => { | |
const data = JSON.parse(message.data); | |
if (data.event === 'ms.channel.connect') { | |
ws.send(JSON.stringify({ | |
method: 'ms.remote.control', | |
params: { | |
TypeOfRemote: 'SendRemoteKey', | |
Cmd: 'Click', | |
Option: 'false', | |
DataOfCmd: 'KEY_MUTE', | |
} | |
})); | |
setTimeout(() => ws.close(), 1000); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment