Open beireken opened 7 years ago
Bart,
No idea if you're still looking at this but I've got a way you can get player state notifications.
Quick disclaimer, I'm completely new to node red!
The idea is to use the telnet interface of your server as this provides notifications. See code here:
[ { "id": "c2c89c2.c09656", "type": "tab", "label": "Flow 5", "disabled": false, "info": "" }, { "id": "b08753d2.2c02c", "type": "debug", "z": "c2c89c2.c09656", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "x": 1030, "y": 120, "wires": [] }, { "id": "4863fc64.3db2a4", "type": "function", "z": "c2c89c2.c09656", "name": "Login and subscribe to notifications", "func": "msg.payload = \"login\\r\\n\";\nnode.send(msg);\nsetTimeout(function() { node.send({\"payload\": \"listen\\r\\n\"});}, 1000);", "outputs": 1, "noerr": 0, "x": 450, "y": 140, "wires": [ [ "4975522c.ff615c" ] ] }, { "id": "20e8d570.bf1ada", "type": "inject", "z": "c2c89c2.c09656", "name": "Start on deploy", "topic": "", "payload": "", "payloadType": "date", "repeat": "", "crontab": "", "once": true, "onceDelay": 0.1, "x": 180, "y": 140, "wires": [ [ "4863fc64.3db2a4" ] ] }, { "id": "4975522c.ff615c", "type": "tcp request", "z": "c2c89c2.c09656", "server": "", "port": "", "out": "sit", "splitc": " ", "name": "Telnet Interface", "x": 590, "y": 240, "wires": [ [ "7fec6bb7.3550f4" ] ] }, { "id": "7fec6bb7.3550f4", "type": "function", "z": "c2c89c2.c09656", "name": "Decode output", "func": "msg.payload = decodeURIComponent(msg.payload.toString());\nreturn msg;", "outputs": 1, "noerr": 0, "x": 850, "y": 180, "wires": [ [ "b08753d2.2c02c" ] ] } ]
The notifications have certain keywords in them which you can search for to trigger particular actions. The notifications also contain the MAC address of the relevant player in case you're only interested in particular devices.
Hope this helps.
Or you can just send the payload "status" to the node:
{
"method":"slim.request",
"result":{"player_name":"player1","player_connected":1,"player_ip":"192.168.x.x:32922","power":1,"signalstrength":0,"mode":"play","time":213.261285188675,"rate":1,"duration":226.655,"can_seek":1,"mixer volume":48,"playlist repeat":0,"playlist shuffle":0,"playlist mode":"off","seq_no":0,"playlist_cur_index":"11","playlist_timestamp":1595598559.85844,"playlist_tracks":12,"digital_volume_control":1},
"params":["b8:27:eb:d6:b6:d8",["status"]],
"ok":true}
Hello,
Are there plans to add a squeezebox-in node to get info from the server/players? More specific it woulb be nice to have player state (play/pause) etc...
Greetings, Bart