Volumio2 Domoticz Connector

Ciao,

I’m working on a script that would be able to reflect the status and the commands between volumio and domoticz(an opensource Home automation software)

The script is written in python and uses SocketIO-client to interact between the 2 systems
everything works pretty fine, I can setup volume (mute-0-100), a basic control (Stop/play/Rew/Fwd) and a text with basic information (status play/stop artirt and title)

I have only one issue (already workarounded, but pretty annoyng):
SocketIO receive the json strings from volumio using single quote instead of double quotes as string delimiter…
this cause a problem in converting from string to json…
I can replace the ’ with the ", but here comes another issue… in case a string contais a single quote (ie: song title It’s my life) then the string delimiter change to double quotes (leaving the others to single)…

this is wired… and cannot figure out how to solve it…
is there a way to force to use " as delimiter?

thanks
ciao
M

I am interested in your solution. Ive been trying to do the same but need an example to start.
Are you willing to share your code?

I myself use domoticz as well.
I made a dummy selector switch and with that i can control my Volumio (i do not use volume control)
I have node red and the mqqt plugin on the domoticz pi running
To get the feedback from Volumio in domoticz i created a dummy text switch and the input to that switch i take from a very simple node red script. (i am not a programmer)



If you are interested i can post my script here.

Hi, your project interests me, how did you make parametrer volumio2 in Domoticz? I will also be interested in your script. How to integrate it domoticz?
thank you in advance
jp

@mveldman : Im very intrested in your script, would really like to test it out on my system :slight_smile: So if you still want to share it, pls do :smiley:

[{"id":"3c145eae.2bbb82","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""},{"id":"70c89d92.a02dbc","type":"debug","z":"9a83b293.9f7e","name":"Status","active":true,"console":"false","complete":"payload","x":728.5,"y":90,"wires":[]},{"id":"77e38c66.76058c","type":"http request","z":"9a83b293.9f7e","name":"Volumio","method":"GET","ret":"obj","url":"http://volumio.local/api/v1/getstate","x":277.5,"y":225,"wires":[["dc4e9e48.fd83d","7f3517aa.71bdf8"]]},{"id":"5f9d4792.c7b4f","type":"inject","z":"9a83b293.9f7e","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":128.5,"y":220,"wires":[["77e38c66.76058c"]]},{"id":"dc4e9e48.fd83d","type":"function","z":"9a83b293.9f7e","name":"Speler aan of uit","func":"var Spelerstatus=msg.payload.status;\nif(Spelerstatus=='play')\n{var speelstatus=1}\nelse\n{var speelstatus=0}\nmsg.payload.nvalue = speelstatus;\nmsg.payload.idx = 124;\nreturn msg\n","outputs":1,"noerr":0,"x":485.5,"y":198,"wires":[["7fe4ef92.30e1c8","70c89d92.a02dbc"]]},{"id":"7fe4ef92.30e1c8","type":"mqtt out","z":"9a83b293.9f7e","name":"Volumio status","topic":"domoticz/in","qos":"","retain":"","broker":"3c145eae.2bbb82","x":719.5,"y":203,"wires":[]},{"id":"7f3517aa.71bdf8","type":"function","z":"9a83b293.9f7e","name":"Welke song","func":"var songtitle=msg.payload.title;\nvar artist=msg.payload.artist;\nvar output=artist + ' : ' + songtitle;\nmsg.payload.svalue = output;\nmsg.payload.idx = 114;\nreturn msg","outputs":1,"noerr":0,"x":473.5,"y":289,"wires":[["7fe4ef92.30e1c8","70c89d92.a02dbc"]]}]

This is my exported script from node-red.
Keep in mind that node-red is on the same pi as domoticz.
Volumio is on a different machine.
The idx of your switches would probably be different from the ones on my domoticz

Thank you, will test this as soon as I have some time to dig in to this project :slight_smile:

@mveldman : I have now tested the script and I can get the right output from node-red. But how do I get the info in Domoticz, I have created a dummy text switch. Do you have a dzvent script or something that reads from node-red?

Thanks!

Ok, I got working :slight_smile:. Thanks for the script @mveldman

Great!
You’re welcome.

Hi there

I am trying to install node red on my RPI 3 running the newest Volumio(2.457) but every time I do so the web interface crashes. I can’t connect to web interface in any browsers of at the official iOS App. I can still access the Pi over SSH through… I have also tried not to install the specific Pi nodes but no success there…

Does any of you successfully installed Node red on your RPI running Volumio?

I am using this guide: https://nodered.org/docs/hardware/raspberrypi

Thanks in advance :slight_smile:

Regards Mikkel

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": ""
    }
]