From Domoticz
Jump to: navigation, search


A native integration of the Sonos wireless music system in Domoticz is something that I think would be highly appreciated by a lot of Domoticz users. Unfortunately until now there is no hardware support included by default. User m_g_s_g started to work on a native Sonos plugin for a while but unfortunately he abandoned the project. The code is still on GitHub waiting for someone to pick this up and continue his work.

Next to the native plugin there are multiple other solutions available by using scripts. Below the ones that can be found on the forum:

  • Easy Sonos
  • Node Sonos HTTP API
  • Wrapper for PHPSonos
  • Sonos Soco Plugin

Easy Sonos

The instructions below are based on this topic thanks to Marmo

  • Download from the file sonos.class.php and copy it to your scripts directory
  • Install PHP and PHP5 curl if it is not installed on your machine. So sudo apt-get install php5-cli php5-curl (in Debian).
  • To do an easy test, create two separate scripts for PLAY ( and PAUSE (sonos.pause.php), both similar except in the command itself. As follows (only change the IP address to the IP of your Sonos):
#!/usr/bin/env php
$IP_sonos_1 = "";
$sonos_1 = new SonosPHPController($IP_sonos_1);
$sonos_1 = $sonos_1->Play();
  • chmod u+x the created play and pause files
  • Call them from a virtual switch like this: script:///path to domoticz dir/domoticz/scripts/

Wrapper for PHPSonos

This works similar to the Easy Sonos solution. The only difference is that you need to have a PHP enabled webserver in order to have this working. User G3rard forked the original wrapper by ThomasTr and improved it a bit for use with Domoticz. This also includes text to speach functionality.

To install this follow the instructions as described here.

Node Sonos HTTP API

Another solution is to use the Node Sonos HTTP API. There is a nice step-by-step guide on the forum made by Holland, it is a bit more extensive than the instructions below, you can find it here

  • If you don't use the Domoticz SD card image first install node.js from the instructions from the link in point 1 here.
  • log into your machine through a shell and go to the home directory (normally one directory higher than the domoticz directory)
  • git clone node-sonos-http-api
  • cd node-sonos-http-api
  • npm install --production
  • start the server by running npm start
  • Now you can control your system by invoking the following commands:
http://localhost:5005/pauseall[/{timeout in minutes}]
http://localhost:5005/resumeall[/{timeout in minutes}]
http://localhost:5005/preset/{JSON preset}
http://localhost:5005/preset/{predefined preset name}
http://localhost:5005/{room name}/{action}[/{parameter}]
http://localhost:5005/sleep/{timeout in seconds or timestamp HH:MM:SS or off}

More info can be found here

Sonos Soco Plugin

The Soco plugin is based on Python and therefore requires Python 2.7, or 3.2 or newer. (I have not installed this myself so below is just an educational guess)

  • Log into your machine through a shell and go to the home directory (normally one directory higher than the domoticz directory)
  • Install python and python-pip package
  • git clone SoCo
  • cd SoCo
  • pip install soco

More info on SoCo here.

Forum topics for reference