Skip to content

Instantly share code, notes, and snippets.

@fizzyade
Last active April 8, 2024 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fizzyade/25a8f800a1e1db1612fad0f2ad575e46 to your computer and use it in GitHub Desktop.
Save fizzyade/25a8f800a1e1db1612fad0f2ad575e46 to your computer and use it in GitHub Desktop.
Display a message on an Emby device

This flow is allows a message to be displayed on an emby device.

I use this in conjunction with a tv sleep timer flow I have created, this allows me to create a node-red controlled sleep timer and display 60, 30 and 10 second warnings that the TV is about to go off unless the sleep timer is reset or cancelled, I use a raspberry pi zero with the touch-phat to provide “buttons” to control the sleep timer, this means I don’t have to navigate menus in my TV to set sleep mode.

To use this flow you will need to create an api key on your emby server, you should then pass a message to this flow using the following message properties.

  • serverurl the url of the server, for example https://myserver.com:8920 or http://1.2.3.4:8096
  • apikey the api key that you created on the server
  • title the title of notification that will appear on screen
  • payload the message to display
  • timeout the number of milliseconds to display the message for, if this is set to zero then the user will need to manually dismiss the message.

Please note, some Emby devices do not support showing messages.

[{"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"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment