Python : Bose soundtouch Multiroom with domoticz
Posted: Thursday 05 October 2017 13:34
Hello all!
Just wanted to share a library that I found and use in order to command Bose soundtouch speaker with domoticz.
This library is based on the official API provided by Bose so it's very stable and complete.
Link to lib: https://github.com/CharlesBlonde/libsoundtouch
What you can do with this:
- Multiroom (from any sources, presets or airplay)
- commands like play, pause next song...
- Select presets
- Send music from different sources (URL, Spotify)
- Power on or off
I made a script to go with this lib, I didn't found any tutorial or any real examples of how this should work so I thought I'd share mine.
The way this works is you create zones of multiroom with one device as master and others as slaves. After they are all linked together they stay that way until shutdown or restart. Not only you can multiroom with your presets or sources defined in a python script but you can also connect with airplay to the master speaker which will send music to all slaves and the master at the same time.
Sorry for the poor coding, I don't know anything about python and I just made this work. It works in 2 case; with 2 or 3 speaker. This code is not meant to be used as it is but to be used as an example for you to do your own script. Sorry about the French names.
Don't forget to sudo chmod +x your script before using in a switch. Time I can loose on this things

If I can help in any way feel free to ask.
Just wanted to share a library that I found and use in order to command Bose soundtouch speaker with domoticz.
This library is based on the official API provided by Bose so it's very stable and complete.
Link to lib: https://github.com/CharlesBlonde/libsoundtouch
What you can do with this:
- Multiroom (from any sources, presets or airplay)
- commands like play, pause next song...
- Select presets
- Send music from different sources (URL, Spotify)
- Power on or off
I made a script to go with this lib, I didn't found any tutorial or any real examples of how this should work so I thought I'd share mine.
Code: Select all
#!/usr/bin/python
import libsoundtouch
from libsoundtouch import discover_devices
from libsoundtouch import soundtouch_device
from libsoundtouch.utils import Source, Type
from libsoundtouch.device import NoSlavesException, NoExistingZoneException, \
Preset, Config, SoundTouchDevice, SoundtouchInvalidUrlException
devices = discover_devices(timeout=5) # look for soundtouch speaker and put them in a list
n_enceintes = len(devices) # how many speaker are available
if n_enceintes == 2:
enceinte_1, enceinte_2 = devices
print n_enceintes
name_enceinte1 = enceinte_1.config.name
name_enceinte2 = enceinte_2.config.name
if "Ma chambre" in name_enceinte1:
print ("enceinte Ma chambre:" + name_enceinte1)
enceinte_ma_chambre = enceinte_1
if "Salon" in name_enceinte1:
print ("enceinte salon:" + name_enceinte1)
enceinte_salon = enceinte_1
if "Cuisine" in name_enceinte1:
print ("enceinte Cuisine:" + name_enceinte1)
enceinte_cuisine = enceinte_1
if "Ma chambre" in name_enceinte2:
print ("enceinte Ma chambre:" + name_enceinte2)
enceinte_ma_chambre = enceinte_2
if "Salon" in name_enceinte2:
print ("enceinte salon:" + name_enceinte2)
enceinte_salon = enceinte_2
if "Cuisine" in name_enceinte2:
print ("enceinte Cuisine:" + name_enceinte2)
enceinte_cuisine = enceinte_2
if n_enceintes == 3:
enceinte_1, enceinte_2, enceinte_3 = devices
print n_enceintes
name_enceinte1 = enceinte_1.config.name
name_enceinte2 = enceinte_2.config.name
name_enceinte3 = enceinte_3.config.name
if "Ma chambre" in name_enceinte1:
print ("enceinte Ma chambre:" + name_enceinte1)
enceinte_ma_chambre = enceinte_1
if "Salon" in name_enceinte1:
print ("enceinte salon:" + name_enceinte1)
enceinte_salon = enceinte_1
if "Cuisine" in name_enceinte1:
print ("enceinte Cuisine:" + name_enceinte1)
enceinte_cuisine = enceinte_1
if "Ma chambre" in name_enceinte2:
print ("enceinte Ma chambre:" + name_enceinte2)
enceinte_ma_chambre = enceinte_2
if "Salon" in name_enceinte2:
print ("enceinte salon:" + name_enceinte2)
enceinte_salon = enceinte_2
if "Cuisine" in name_enceinte2:
print ("enceinte Cuisine:" + name_enceinte2)
enceinte_cuisine = enceinte_2
if "Ma chambre" in name_enceinte3:
print ("enceinte Ma chambre:" + name_enceinte3)
enceinte_ma_chambre = enceinte_3
if "Salon" in name_enceinte3:
print ("enceinte salon:" + name_enceinte3)
enceinte_salon = enceinte_3
if "Cuisine" in name_enceinte3:
print ("enceinte Cuisine:" + name_enceinte3)
enceinte_cuisine = enceinte_3
enceinte_salon.create_zone([enceinte_cuisine]) # Here "enceinte_salon" is the master "enceinte_cuisine" is the slave
presets = enceinte_salon.presets() #getting presets from master speaker
enceinte_salon.select_preset(presets[0]) # setting preset one one master speaker that will sync with slave/slaves
Sorry for the poor coding, I don't know anything about python and I just made this work. It works in 2 case; with 2 or 3 speaker. This code is not meant to be used as it is but to be used as an example for you to do your own script. Sorry about the French names.
Don't forget to sudo chmod +x your script before using in a switch. Time I can loose on this things


If I can help in any way feel free to ask.