I finally found my way to connecto Volumio2 to my Domoticz
Iwas thinking to create a plugin, but I'm not so skilled, so I choose a Python servicewhich connect via socketIO and keep Domoticz updated, while Domoticz can control Volumio using the http REST API
...if.. for any reason... someone would like toconvert it into a plugin it would be really appreciated!!
here is how it works:
Unfortunately it works only unde linux
in domoticz you need to create 3 dummy devices:
SWITCH DIMMER that will act as volume and mute/unmute
SWITCH SELECTOR that will act as basic controls (PLAY/STOP/PREV/NEXT)
TEXT DEVICEthat will act as a display
Create those 3 and keep note of their IDX
Device Configuration (edit them)
SWITCH DIMMER
- Name: Volumio Volume (you can use whatever you want, but we will is it later)
- Switch Type: Dimmer
- Icon: Speaker
- Save
- Name: Volumio Volume (you can use whatever you want, but we will is it later)
- Switch Type: Selector
- Icon: Amplifier
- Level 0 Name: off (cannot change)
- Level 10 Name:◄◄
- Level 20 Name: ►
- Level 30 Name: ►►
- Level 0 Action : http://<volumio_IP>/api/v1/commands/?cmd=stop
- Level 10 Action: http://<volumio_IP>/api/v1/commands/?cmd=prev
- Level 20 Action: http://<volumio_IP>/api/v1/commands/?cmd=play
- Level 30 Action: http://<volumio_IP>/api/v1/commands/?cmd=next
- Save
http://<volumio_IP>/api/v1/commands/?cmd=playplaylist&name=<playlist Name>
The TEXT DEVICE does not need any special configuration except its name
now you need to create a dzVents Script in which you can copy/paste the following:
Code: Select all
return {
active = true,
on = { devices = {'Volumio Volume'} },-- NUse the same name as setted in the Volume device
execute = function(dz, devVol)
local volumio = '<volumio_IP>'
if devVol.state == 'Off' then
os.execute('curl "http://'..volumio ..'/api/v1/commands/?cmd=volume&volume=mute"')
else
os.execute('curl "http://'..volumio ..'/api/v1/commands/?cmd=volume&volume='..devVol.level..'"')
end
end
}
now save the attached file in a folder into your linux system
Connect in Telnet/SSH to your linux system
be sure you have SocketIO installed by issuing
Code: Select all
sudo pip3 install SocketIO-client
Code: Select all
VOLUIP = '<Volumio_IP>'
DEVIDX = '000' # VOLUME CONTROL
DEVTXT = '000' # DISPLAY CONTROL
DEVCTL = '000' # DEVICE CONTROL
now let's create the service (these instruction works under Raspberry, other systems may need an adjustment:
Code: Select all
sudo nano /lib/systemd/system/dzVol.service
Code: Select all
[Unit]
Description=Volumio connector for Domoticz
After=multi-user.target
[Service]
User=root
Type=idle
ExecStart= /home/pi/utility/dzVol.py
[Install]
WantedBy=multi-user.target
now some other command to complete the installation:
Code: Select all
sudo chmod +x /home/pi/utility/dzVol.py
sudo chmod +x /lib/systemd/system/dzVol.service
sudo systectl daemon-reload
sudo systemctl enable dzVol.service
sudo systemctl start dzVol.service
sudo systemctl status dzVol.service
...that's all... you should be now able to change volume and use command on both domoticz and volumio UI to have the other side updated
hope you enjoy it
let me know what you think about it
ciao
M