plugin.Name = "OnkyoReceiverTX-NR838"; plugin.OnChangeRequest = onChangeRequest; plugin.OnConnect = onConnect; plugin.OnDisconnect = onDisconnect; plugin.OnPoll = onPoll; plugin.OnSynchronizeDevices = onSynchronizeDevices; plugin.PollingInterval = -1; plugin.DefaultSettings = { "Host": "192.168.4.7", "Port": 60128 }; var deviceId = "1"; var socket = new TCPClient(); var commands = { "InputBD/DVD": [ISCP, x00, x00, x00, x10, x00, x00, x00, x08, x01, x00, x00, x00, !1SLI10, x0D, x0A0xFF, 0xEE, 0xEE, 0xEE, 0xDD], "ScreenStop": [0xFF, 0xEE, 0xEE, 0xEE, 0xCC], "ScreenDown": [0xFF, 0xEE, 0xEE, 0xEE, 0xEE], } function onChangeRequest(device, attribute, value) { if (attribute != "MediaCommand") throw "Invalid attribute"; var command = commands[value]; if (!command) throw "Invalid command"; socket.send(command); } function onConnect() { socket.connect(plugin.Settings["Host"], parseInt(plugin.Settings["Port"])); var device = plugin.Devices[deviceId]; if (device != null) { device.SupportedMediaCommands = Object.keys(commands); } } function onDisconnect() { socket.close(); } function onPoll() { } function onSynchronizeDevices() { var device = new Device(); device.Id = deviceId; device.DisplayName = "OnkyoTXNR838"; device.Capabilities = ["MediaControl"]; device.Attributes = []; plugin.Devices[deviceId] = device; }