FredThx / node-red-contrib-squeezebox

a node-red node for squeezebox server interface.
Other
3 stars 2 forks source link

squeezebox-in #1

Open beireken opened 7 years ago

beireken commented 7 years ago

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

elParaguayo commented 4 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.

theoo commented 4 years ago

Or you can just send the payload "status" to the node: