plugin.Name = "NetIO"; plugin.OnChangeRequest = onChangeRequest; plugin.OnConnect = onConnect; plugin.OnDisconnect = onDisconnect; plugin.OnPoll = onPoll; plugin.OnSynchronizeDevices = onSynchronizeDevices; plugin.PollingInterval = -1; plugin.DefaultSettings = { "Host": "192.168.68.208" }; var http = new HTTPClient(); var baseUrl; var commands = { "PowerOff": "/sendRF?code=4117&bits=24&n=1", "PowerOn": "/sendRF?code=4117&bits=24&n=1", } function onChangeRequest(device, attribute, value) { if (attribute != "MediaCommand") throw "Invalid attribute"; var command = commands[value]; if (!command) throw "Invalid command"; console.log("sending=> " + baseUrl + command); http.get(baseUrl + command); } function onConnect() { baseUrl = "http://" + plugin.Settings["Host"] + ""; var mediaCenter = plugin.Devices["1"]; if (mediaCenter != null) { mediaCenter.SupportedMediaCommands = Object.keys(commands); } } function onDisconnect() { } function onPoll() { } function onSynchronizeDevices() { var mediaCenter = new Device(); mediaCenter.Id = "1"; mediaCenter.DisplayName = "NetIO"; mediaCenter.Capabilities = ["MediaControl"]; mediaCenter.Attributes = []; plugin.Devices[mediaCenter.Id] = mediaCenter; }