Display textmessage on Squeezebox devices
This flow enables text, which is received from a message on the squeezebox\sendmessage MQTT topic, to be displayed on all connected Squeezebox devices.
For this flow a working LMS (Logitech Media Server) is required, which listens on the 9090 port (default telnet port of LMS), and a working MQTT broker.
Setup instructions: Included in the flow (on the right side next to the Information nodegroup).
Usage example:
When it's about to rain in the next 15 minutes I let NodeRed send a MQTT message to the "squeezebox\sendmessage" topic with the text "x.x mm rain expected in the next 15 minutes.".
When someone presses the doorbel, I let NodeRed send a message to the "squeezebox\sendmessage" topic with the text "Doorbell ringing".
[{"id":"c5b8cc2d73383a36","type":"tab","label":"Squezebox notification text","disabled":false,"info":"","env":[]},{"id":"8c4cb8ef3bfd5429","type":"group","z":"c5b8cc2d73383a36","name":"Test & Debug section","style":{"label":true,"stroke":"none","color":"#777777","fill":"#87a980","fill-opacity":"0.1"},"nodes":["a8d19312.bb8738","fd77b99f45c726ed","4e1fce40b46d8f04","58c851379d66f0fd"],"x":14,"y":419,"w":1572,"h":122},{"id":"c1f5b142f6f6c64e","type":"group","z":"c5b8cc2d73383a36","name":"Information","style":{"fill":"#d1d1d1","fill-opacity":"0.2","label":true,"stroke":"none","stroke-opacity":"0.75","color":"#777777"},"nodes":["50c28b302f85b417","3a1a91b161464c23","a4126ce4b238367c"],"x":14,"y":19,"w":1012,"h":202},{"id":"8797e73bdc44621d","type":"group","z":"c5b8cc2d73383a36","name":"Main flow","style":{"fill":"#0070c0","fill-opacity":"0.1","label":true,"color":"#777777","stroke":"none"},"nodes":["37911fd8.406e5","ed303d6248baf22d","e49caf3c817b237f","603a9301dd088ae6","582071992e941a64","debd36b377cd0dd7","a8b827cfc272e78b","29b8c397107ff754"],"x":14,"y":259,"w":1152,"h":122},{"id":"607b0654415e19ed","type":"group","z":"c5b8cc2d73383a36","name":"Setup instructions","style":{"stroke":"none","fill":"#d1d1d1","label":true,"fill-opacity":"0.2","color":"#777777"},"nodes":["5915adad8e052c98","3dbeeeb964e0d3c9","e64abbf3443a679c","c7a3a34c83819fe3"],"x":1054,"y":19,"w":812,"h":202},{"id":"a8d19312.bb8738","type":"inject","z":"c5b8cc2d73383a36","g":"8c4cb8ef3bfd5429","name":"Send test message","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Manual testmessage from NodeRed","payloadType":"str","x":150,"y":460,"wires":[["ed303d6248baf22d"]]},{"id":"fd77b99f45c726ed","type":"mqtt out","z":"c5b8cc2d73383a36","g":"8c4cb8ef3bfd5429","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"4ac4176a3ecc81a5","x":370,"y":500,"wires":[]},{"id":"4e1fce40b46d8f04","type":"inject","z":"c5b8cc2d73383a36","g":"8c4cb8ef3bfd5429","name":"Send test message via MQTT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"squeezebox/sendmessage","payload":"Manual testmessag via MQTT Nodered","payloadType":"str","x":180,"y":500,"wires":[["fd77b99f45c726ed"]]},{"id":"58c851379d66f0fd","type":"debug","z":"c5b8cc2d73383a36","g":"8c4cb8ef3bfd5429","name":"Debug squeezebox sendmessage output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1380,"y":460,"wires":[]},{"id":"50c28b302f85b417","type":"comment","z":"c5b8cc2d73383a36","g":"c1f5b142f6f6c64e","name":"Version: v1.0 - 16-6-2024 First release.","info":"","x":210,"y":100,"wires":[],"icon":"font-awesome/fa-life-saver"},{"id":"3a1a91b161464c23","type":"comment","z":"c5b8cc2d73383a36","g":"c1f5b142f6f6c64e","name":"Usage: Just send a MQTT message to the topic \"squeezebox/sendmessage\" and the message will be displayed on all connected Squeezeboxes.","info":"","x":520,"y":180,"wires":[],"icon":"font-awesome/fa-info"},{"id":"a4126ce4b238367c","type":"comment","z":"c5b8cc2d73383a36","g":"c1f5b142f6f6c64e","name":"Display text on Squeezebox devices","info":"","x":180,"y":60,"wires":[],"icon":"font-awesome/fa-sitemap"},{"id":"37911fd8.406e5","type":"tcp request","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"","server":"YOUR_LMS_SERVERADRESS","port":"9090","out":"immed","ret":"buffer","splitc":" ","newline":"","trim":false,"tls":"","x":980,"y":340,"wires":[["58c851379d66f0fd"]]},{"id":"ed303d6248baf22d","type":"change","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"Set line1 text and duration","rules":[{"t":"set","p":"line1","pt":"msg","to":"Nodered","tot":"str"},{"t":"set","p":"duration","pt":"msg","to":"5","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":340,"wires":[["e49caf3c817b237f"]]},{"id":"e49caf3c817b237f","type":"function","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"Format command to send","func":"// Build commandline\nmsg.payload = \"show line1:\" + msg.line1 + \" line2:\" + urlEncodeString(msg.payload) + \" duration:\" + msg.duration + \"\\n\";\n\n// Return the modified message object\nreturn msg;\n\n// Function to URL-encode each character in the input string\nfunction urlEncodeString(input) {\n let result = '';\n for (let i = 0; i < input.length; i++) {\n let charCode = input.charCodeAt(i);\n if (charCode < 33 || charCode > 126) { // Non-printable range\n result += '%' + charCode.toString(16).toUpperCase().padStart(2, '0');\n } else {\n result += input[i];\n }\n }\n return result;\n}","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":340,"wires":[["37911fd8.406e5"]]},{"id":"603a9301dd088ae6","type":"mqtt in","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"","topic":"squeezebox/sendmessage","qos":"2","datatype":"auto-detect","broker":"4ac4176a3ecc81a5","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":340,"wires":[["ed303d6248baf22d"]]},{"id":"582071992e941a64","type":"comment","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"Set parameters","info":"","x":420,"y":300,"wires":[]},{"id":"debd36b377cd0dd7","type":"comment","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"Prepare command","info":"","x":670,"y":300,"wires":[]},{"id":"a8b827cfc272e78b","type":"comment","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"Transmit message via telnet","info":"","x":940,"y":300,"wires":[]},{"id":"29b8c397107ff754","type":"comment","z":"c5b8cc2d73383a36","g":"8797e73bdc44621d","name":"Listen for message on MQTT topic","info":"","x":180,"y":300,"wires":[]},{"id":"5915adad8e052c98","type":"comment","z":"c5b8cc2d73383a36","g":"607b0654415e19ed","name":"1. Replace YOUR_LMS_SERVERADDRESS in the \"tcp ...\" node. (Note: The default LMS telnet port is 9090)","info":"","x":1450,"y":60,"wires":[],"icon":"font-awesome/fa-step-forward"},{"id":"3dbeeeb964e0d3c9","type":"comment","z":"c5b8cc2d73383a36","g":"607b0654415e19ed","name":"3. [optional] Change the \"line 1\" text. (Note: The default line1 text =: Nodered).","info":"","x":1350,"y":140,"wires":[],"icon":"font-awesome/fa-step-forward"},{"id":"e64abbf3443a679c","type":"comment","z":"c5b8cc2d73383a36","g":"607b0654415e19ed","name":"4. [optional] Change the text display duration (default = 5 (seconds)).","info":"","x":1320,"y":180,"wires":[],"icon":"font-awesome/fa-step-forward"},{"id":"c7a3a34c83819fe3","type":"comment","z":"c5b8cc2d73383a36","g":"607b0654415e19ed","name":"2. Replace the YOUR_MQTT_BROKER_ADDRESS and the YOUR_CLIENT_ID in the mqtt-broker config node.","info":"","x":1460,"y":100,"wires":[],"icon":"font-awesome/fa-step-forward"},{"id":"4ac4176a3ecc81a5","type":"mqtt-broker","name":"","broker":"YOUR_MQTT_BROKER_ADDRESS","port":"1883","clientid":"YOUR_CLIENT_ID","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]