Tutorial: How to control Sonos speakers with the hub


#1

This tutorial will show you how to use Mixtile Hub to control your Sonos speakers. By the end of the tutorial, you should be able to control your Sonos devices from Paper UI and create routines using your Sonos devices such as automatically play music when motion is detected.

To get the hub to work with Sonos, you’ll need to install the Sonos binding to the hub. If you’ve changed your default Eclipse Smarthome (ESH) framework to openHAB, you can go to Paper UI and find Sonos binding from Add-ons. However, if you’re using ESH framework, then you can download the binding from openHAB and manually add it to the hub.

(The binding works with the following all available Sonos (playback) devices such as One, Play:1, Play:3, Play:5, Connect, Connect:Amp, Playbar, Playbase, Beam and Sub.)

Follow the steps below to port the Sonos binding to ESH.

  1. Download the add-ons (kar) file from openHAB website. (This file contains all the bindings for openHAB)

  2. Unzip the kar file then find the jar file for Sonos. It should look something like

    • org.eclipse.smarthome.binding.sonos-0.10.0.oh240.jar
  3. Copy this jar file to Mixtile Hub

    • scp org.eclipse.smarthome.binding.sonos-0.10.0.oh240.jar user@*hub_ip_address*:/home/user (ignore the *s)
  4. SSH into the hub and get root access

    • ssh user@*hub_ip_address* (password is the SN code)
    • sudo -i
  5. Stop the hub

    • systemctl stop mhub.service
  6. Change the ownership of the jar file to mhub, then move it to org.eclipse.smarthome directory

    • cd /home/user
    • chown mhub. org.eclipse.smarthome.binding.sonos-0.10.0.oh240.jar
    • mv org.eclipse.smarthome.binding.sonos-0.10.0.oh240.jar /opt/mhub/runtime/concierge/system/org.eclipse.smarthome
  7. Edit the smarthome.xargs file to include the Sonos binding

    • cd /opt/mhub/runtime/concierge/
    • vi smarthome.xargs
    • (Scroll all the way down the file to #Mixtile bindings, then include the following line in the file)
      -istart ${esh.dir}/org.eclipse.smarthome.binding.sonos-0.10.0.oh240.jar
      image
  8. You have successfully added the Sonos binding to the hub. Now, start the hub

    • systemctl start mhub.service
  9. Wait a few minutes for hub to start up. Then open a browser and type in the following address to access Paper UI

    • *hub_ip_address*:8080 (ignore the *s)
  10. If your Sonos device(s) is connected to the same network as the hub, it will be automatically detected. Head to inbox to add your Sonos device.
    image

  11. If your Sonos device is missing the ‘Media Control’ and ‘Volume’ features, go to ‘Configuration > Things > (Sonos device)’. You should see a list of channels below. Click ‘Show More’ and find the missing features. If they are NOT present, we will have to add them manually. Proceed to the next steps!

  12. SSH to the hub and get root access again (step 4). Stop the hub (step 5)!

  13. Modify the org.eclipse.smarthome.core.thing.Thing.json to include the media player and volume channels

    • cd /config/mhub/userdata/jsondb
    • vi org.eclipse.smarthome.core.thing.Thing.json
    • (Find the Sonos device, you should see a list of channels under it. Add ‘Media Player’ and ‘Dimmer’ channels. See picture below)
  14. Now, start the hub

    • systemctl start mhub.service
  15. Once the hub finished starting up. Go back to Paper UI and link the new channels

    • *hub_ip_address*:8080 (ignore the *s)
    • (Go to ‘Configuration > Things > (Sonos device)’, click ‘Show More’. Select the media control and volume channels)
      image

That’s it! Note that you can see the Sonos device from the Mixtile app, but you can’t control it yet. For now, you can Paper UI to control your Sonos devices. You can also create routines (rules) on Paper UI and they will work. Give it a try and create a routine with the Sonos device!
For more info on this binding, visit