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": [0x49, 0x53, 0x43, 0x50, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x21, 0x31, 0x53, 0x4c, 0x49, 0x31, 0x30, 0x0d], "InputSKY": [0x49,0x53,0x43,0x50,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x00,0x21,0x31,0x53,0x4c,0x49,0x32,0x33,0x0D,0x0A], "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; }