|
[{"id":"b505a3ead3fa92e2","type":"tab","label":"Emby Message","disabled":false,"info":"\n<p>Displays a message on an emby device.</p>\n\n<h3>Inputs</h3>\n <dl class=\"message-properties\">\n <dt>apikey\n <span class=\"property-type\">string</span>\n </dt>\n <dd> the emby api key. </dd> \n <dt>serverurl\n <span class=\"property-type\">string</span>\n </dt>\n <dd> the url of the emby server. </dd>\n <dt>payload\n <span class=\"property-type\">string</span>\n </dt>\n <dd> the message to display. </dd>\n <dt>title\n <span class=\"property-type\">string</span>\n </dt>\n <dd> the title of the message. </dd>\n <dt>timeout\n <span class=\"property-type\">number</span>\n </dt>\n <dd> the message timeout in milliseconds. </dd>\n </dl>\n\n\n\n\n"},{"id":"3bd8cc611f122637","type":"http request","z":"b505a3ead3fa92e2","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"{{{emby.url}}}/emby/Devices?api_key={{{emby.apikey}}}","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":440,"wires":[["04848dcb819c8815"]]},{"id":"04848dcb819c8815","type":"function","z":"b505a3ead3fa92e2","name":"find device","func":"for(var i=0;i<msg.payload.Items.length;i++) {\n if (msg.payload.Items[i].Name==msg.emby.device) {\n msg.emby.deviceId = msg.payload.Items[i].ReportedDeviceId\n\n node.send(msg)\n }\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":480,"wires":[["64d88b903df34d70"]]},{"id":"64d88b903df34d70","type":"http request","z":"b505a3ead3fa92e2","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"{{{emby.url}}}/emby/Sessions?api_key={{{emby.apikey}}}","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":520,"wires":[["d8629b877e3fd802"]]},{"id":"d8629b877e3fd802","type":"function","z":"b505a3ead3fa92e2","name":"find session","func":"for(var i=0;i<msg.payload.length;i++) {\n if (msg.payload[i].DeviceId==msg.emby.deviceId) {\n\n msg.url = msg.emby.url+\"/emby/Sessions/\"+msg.payload[i].Id+\"/Message?Text=\"+msg.emby.message+\"&Header=\"+msg.emby.title+\"&TimeoutMs=\"+msg.emby.timeout.toString()+\"&api_key=\"+msg.emby.apikey\n msg.payload = ''\n \n node.send(msg)\n }\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":560,"wires":[["6ed122df3089b976"]]},{"id":"6ed122df3089b976","type":"http request","z":"b505a3ead3fa92e2","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":600,"wires":[[]]},{"id":"6e92616303479cc9","type":"function","z":"b505a3ead3fa92e2","name":"initialise","func":"msg.emby = {}\n\nmsg.emby.url = msg.serverurl\nmsg.emby.apikey = msg.apikey\nmsg.emby.device = msg.device\nmsg.emby.message = msg.payload\nmsg.emby.title = msg.title\nmsg.emby.timeout = msg.timeout\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":400,"wires":[["3bd8cc611f122637"]]},{"id":"b83bb1b8d24c5e2a","type":"link in","z":"b505a3ead3fa92e2","name":"sendEmbyMessage","links":["f3c60bc3.f788f8"],"x":215,"y":400,"wires":[["6e92616303479cc9"]]}] |