Ok - my code is not even close to be presentable, but here's an intro to get you started. Full control of your squeezebox players is trivial starting from here ...
https://github.com/piotrraczynski/squeezenodeUnzip squeezenode.zip (remove "-master"), so it's here:
~/.node-red/node_modules/squeezenode
Add this to the "functionGlobalContext: {" section of your settings.js:
squeezebox:require('~/.node-red/node_modules/squeezenode')
Restart node-red
Most of the functions you need are in "squeezeplayer.js".
For example to toggle pause on your squeezebox player, the functions is:
this.pause = function (callback) {
this.request(playerId, ["pause"], callback);
};
Here's the node-red importable code, that implements the toggled pause, and also code that returns a string showing name of current track.
[{"id":"8dbd6fd5.11bdc","type":"inject","z":"a451b65e.e3e48","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1346.6666259765625,"y":731.6665859222412,"wires":[["23ed90d5.d73628"]]},{"id":"23ed90d5.d73628","type":"function","z":"a451b65e.e3e48","name":"play","func":"var SqueezeServer = global.get('squeezebox'); //require('~/.node-red/node_modules/squeezenode');\nvar squeeze = new SqueezeServer('
http://localhost', 9000);\nsqueeze.on('register', function(){\n\tsqueeze.players[\"00:1f:1f:a9:a2:95\"].play();\n});\nreturn msg;","outputs":1,"noerr":0,"x":1499.4881591796875,"y":731.4046936035156,"wires":[[]]},{"id":"ee54bb1c.b04dd","type":"debug","z":"a451b65e.e3e48","name":"","active":true,"console":"false","complete":"true","x":1737.1547927856445,"y":776.666606426239,"wires":[]},{"id":"b02a9618.af7e9","type":"function","z":"a451b65e.e3e48","name":"get current track title","func":"var SqueezeServer = global.get('squeezebox'); //require('~/.node-red/node_modules/squeezenode');\nvar squeeze = new SqueezeServer('
http://localhost', 9000);\nsqueeze.on('register', function(){\n\t \tsqueeze.players[\"00:1f:1f:a9:a2:95\"].getCurrentTitle(function(response){\n\t \t node.send(response.result);\n \t\t});\n});\n","outputs":1,"noerr":0,"x":1548.5831336975098,"y":777.1428852081299,"wires":[["ee54bb1c.b04dd"]]},{"id":"91436022.d771d","type":"inject","z":"a451b65e.e3e48","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1343.3332977294922,"y":777.7619018554688,"wires":[["b02a9618.af7e9"]]}]
You'll need to change the squeeze.players ID to match yours (or create a node to choose one), and update the ip for your Logitechmediaserver - mine is on localhost.
My target functionality was to get all my squeezeboxes to play speech sent as text via MQTT (e.g. "doorbell pressed", or something silly like that).
The process flow is thus:
MQTT publish "doorbell pressed"
Read the relevant topic
Send the text to Watson text to speech
Received the speech data (FLAC), save to file
Clear the LMS playlist
Enqueue the file to the playlist
Play
Total timelag between publishing the required text to MQTT, and hearing it out of each of my squeezeboxes, can't be more than about a second, so it's very usable.
Many thanks to Piotr for the excellent but simple to use JS squeezenode interface. I can see that it does all I need and much more.