Hi
Here is my code (node-red nodes) to have my volumio server state in Domoticz (it does’nt send any command to volumio).
Read the README node to have more information.
The MQTT Broker (node-red) is installed on the same server as Domoticz (not on Volumio media player)
Have fun, #StayAtHome and listen Music!
[
{
"id": "38e2ba4e.984346",
"type": "tab",
"label": "Volumio",
"disabled": false,
"info": ""
},
{
"id": "8bf936f.5f1fe48",
"type": "debug",
"z": "38e2ba4e.984346",
"name": "Debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 650,
"y": 200,
"wires": []
},
{
"id": "21019229.506c56",
"type": "http request",
"z": "38e2ba4e.984346",
"name": "Volumio",
"method": "GET",
"ret": "obj",
"paytoqs": false,
"url": "http://volumio.local/api/v1/getstate",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 280,
"y": 120,
"wires": [
[
"788e5a6d.a36c3c"
]
]
},
{
"id": "a26946ab.e5d428",
"type": "inject",
"z": "38e2ba4e.984346",
"name": "Start",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "30",
"crontab": "",
"once": true,
"onceDelay": "1",
"x": 90,
"y": 120,
"wires": [
[
"21019229.506c56"
]
]
},
{
"id": "788e5a6d.a36c3c",
"type": "function",
"z": "38e2ba4e.984346",
"name": "Etat du Player",
"func": "/*** Set your Domoticz Volumio switch IDX here ***/\nvar Volumio_IDX = 156;\n/*** END Configuration ****/\n\n\nvar playstatus = 0;\nvar output = 'Off';\nvar previousPlay = flow.get(\"previous\")||'';\nvar duration = 30;\nvar seek = 0;\n\nvar PlayerStatus = msg.payload.status;\nif( PlayerStatus == 'play'){\n playstatus = 5;\n var songtitle = msg.payload.title;\n var artist = msg.payload.artist;\n var album = msg.payload.album;\n output = artist + ' , ' + songtitle + ' (' + album + ')';\n duration = msg.payload.duration ;\n seek = msg.payload.seek\n} else if( PlayerStatus == 'stop') {\n playstatus = 1;\n output = 'On'\n}\n\nif ( previousPlay == output)\n return; \n \nflow.set(\"previous\",output);\n\nnewMsg = {'command': 'udevice','idx' : Volumio_IDX,'nvalue' : playstatus, 'svalue' : output , 'duration' : duration, 'seek' : seek };\nvar VolumioStatus = {\"payload\" : newMsg };\nreturn VolumioStatus;",
"outputs": 1,
"noerr": 0,
"x": 480,
"y": 120,
"wires": [
[
"ad27c402.9faab8",
"cb60ae6f.825b7"
]
]
},
{
"id": "ad27c402.9faab8",
"type": "mqtt out",
"z": "38e2ba4e.984346",
"name": "Volumio status",
"topic": "domoticz/in",
"qos": "",
"retain": "",
"broker": "1afa89e4.a6fd86",
"x": 700,
"y": 120,
"wires": []
},
{
"id": "cb60ae6f.825b7",
"type": "function",
"z": "38e2ba4e.984346",
"name": "Duration",
"func": "/* Duration en secondes, seek en millisecondes, delay en millisecondes */\nvar delay = Number(msg.payload.duration) * 1000 - Number(msg.payload.seek) + 1000;\nsetTimeout(function(){\n msg['payload'] = 'finished';\n node.send(msg);\n}, delay);",
"outputs": 1,
"noerr": 0,
"x": 380,
"y": 40,
"wires": [
[
"21019229.506c56"
]
]
},
{
"id": "5609512b.10a1",
"type": "comment",
"z": "38e2ba4e.984346",
"name": "README",
"info": "This is a nodered nodes configuration to have volumio informations on your domoticz system.\n# \nFirst create a dummy Media Player on your Domoticz System (create it from the Lightswitches board in a dummy hardware).\n\nYou've to install an MQTT Broker into nodered before use this code.\nTo install MQTT Broker\n% cd ~/.node-red && npm install node-red-contrib-mqtt-broker\n\n\nEdit the \"Etat du Player\" node and set the \nvar Volumio_ID to your dummy Media Player idx \n\n\nNote: If your volumio server fullname is not volumio.local, edit the Volumio node and replace http://volumio.local by your volumio fullname.",
"x": 120,
"y": 220,
"wires": []
},
{
"id": "1afa89e4.a6fd86",
"type": "mqtt-broker",
"z": "",
"name": "NodeBroker",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]