[Node-Red] Tutorial to use your Sonos speakers

Add Sonos Speaker with Node Red in Gladys

We will be able to control Sonos-type speakers.
Our assistant will be able to launch playlists, radios, etc. previously saved in the Sonos app. (My Sonos tab - First tab with a star)

The first part concerns Gladys, the second Node Red, and the third part will be for the evolutions.

Thanks to @spenceur for his tutorial which I greatly inspired myself from.

Configuration in Gladys

Prerequisites

  • Have your MQTT broker configured on Gladys
  • Know how to handle the creation of virtual devices

Step

  1. To begin, you need to create your speaker in Gladys via the MQTT service in this way:

  1. Fill in a name, an external id for the MQTT server, the room, then save:

  1. Once this is done, do not leave the page but add the feature:

Fonctionnalites

The configuration on the Gladys side is complete, we will move on to Node Red.

Configuration on Node Red

Prerequisites

  • Install the node-red-contrib-sonos-plus and node-red-contrib-sonos-events packages
  • Have the MQTT connection configured in Node Red for the connection with Gladys

Step

  1. Add an MQTT in node: image

  2. Add the topic previously created in Gladys

  3. Add a « switch Â» node: switch

  4. Edit the « switch Â» node by adding two payloads as follows:

  5. Create two universal SONOS nodes sonos, connect them to the switch outputs, and configure them as follows:

  1. Deploy the NODE Red solution:

Evolution

  • It would be interesting to be able to create virtual buttons of the type: Play/Pause, Vol+, Vol-, next, launch of a selected playlist, etc. Some of these features are available in the television part but no feedback on the dashboard of the type virtual buttons.

  • It is possible to retrieve the playlist, the track being listened to. Would it be possible to send this information to Gladys via an MQTT out?

2 Likes

Thanks for this tutorial, really nice!! :slight_smile:

I’m moving it to the « Tutorials Â» section of the forum.

Indeed, for now there is no controller in the UI for this type of device.

For now we don’t have music management in Gladys 4, but it would be great to have it I agree :slight_smile: It’s a complete development, we need to think about the data format, the UI, etc..

1 Like

Thanks to you for you @loic_btz for your tutorial that will be very useful to me!

1 Like