That’s a mouthful of a title, but if you’re here, it’s because you know the pain. You’ve got a fancy new smart button, and it works with Matter. You want to press it and enter a party mode that fires up the latest K-Pop Demon Hunters track from Spotify on your Sonos speaker. We've all been there. This really should be a simple task, but it isn’t. Matter doesn’t support Sonos, Sonos doesn’t support Spotify in an automation, and nothing works!
If you have Home Assistant, it’s perfectly possible. I won’t say it’s easy, because it isn’t. But it is possible, and here’s how to do it.
But I don't use Home Assistant!
Neither do I; the UI is too complex for everyday use. I prefer the Apple Home interface for quickly managing smart home accessories. I pull down from the top of my iPhone's screen, and it's there.
But the beauty of Matter is that not only are you not restricted in which platform to choose, you can even run multiple smart home controllers simultaneously, and they can all access the same Matter devices and sensors. So, while Home Assistant isn't my primary choice of smart home controller, it's great for automating things that just aren't possible on other platforms. It the duct tape behind the scenes that connects things that otherwise don't want to be connected.
Adding a Home Assistant Green or Yellow box to your home is a great way to get started. You can tinker with all these DIY hacks and unlock the true power of home automation, and if you find you get on well with the interface, can fully make the switch.
For this tutorial, I'll assume you have Home Assistant set up and running; it may be a fresh installation or something well-established. You should also have added your new Matter buttons. If you've already added them to another controller, don't worry: just open up the settings, and find something like "Enter Pairing Mode". That'll give you a fresh pairing code that you can use to add the buttons to Home Assistant without breaking your existing connections.
Install Music Assistant
While Home Assistant has some basic built-in support for Sonos speakers, if you’ve tried using it to play from Spotify using automation, you’ll know it doesn’t support that. For whatever reason, you can’t start a Spotify playlist remotely. Music Assistant (created by the guy who now heads up Matter efforts within Home Assistant) aims to be for music services and smart speakers what Home Assistant is for smart home. It unifies many different streaming services and smart speakers, allowing interoperability between all of them. And it’s a one-click install for Home Assistant. Don't worry if you've already added Sonos to your Home Assistant; you can leave them alone. Music Assistant will create new entities anyway, and you can continue to use both.
This link should take you directly to the installation page for the Music Assistant add-on in your Home Assistant. If not, navigate to Settings -> Add Ons -> search for "Music Assistant". After the installation, I’d recommend enabling the option to put it in your sidebar for easy access.
Then, over on the Music Assistant dashboard, click the blue button in the top right to add a music streaming service, and choose Spotify (if you don't see the buttons, make sure you're on the settings page; click the three dots in the top right and choose Settings). You’ll need to authenticate, then hit save. Easy! Go ahead and add some more streaming services if needed.
Next up: speakers. That’s what the next button is for: Add Player Providers. You’ll find options for both Sonos and Sonos S1. Use the Enable Network Scan toggle for automatic discovery.
After adding your speakers, you’re basically done with the installation and configuration for Music Assistant. You should find your speakers have been added, and if you navigate using the icons at the bottom, your playlists, artists, tracks, etc are all there. It’s shockingly easy. There's so much we could explore in Music Assistant, but that's outside the scope of this tutorial.
But you’ll also need to add the Music Assistant integration to view your players as Home Assistant entities that can be automated. Go the Settings > Integrations page, and should see an Add button for Music Assistant.
When completed, it'll notify you that new devices have been created.
Automating a button press
Next is the complicated bit. Start by identifying the button you want to automate. Bizarrely, my smart button has six physical buttons to press, but the last one is actually number nine—the first three relate to controlling the internal relays. The easiest way to figure out exactly which button you want is to watch the event logs for the device. Click Logbook from your Home Assistant sidebar. If it's too noisy, add a device filter for your Matter switch. Then press the button!
In the example below, you can see my switch fires off a series of motion events, as well as registering something from button nine. Bingo.
Now, let's add an automation. Click the blue text on the event, then from the three-dot menu, select Device Info. That'll take you directly to the device config page. From here, we want to create a new automation, so click the blue + button next to Automations, and select Create new automation from the menu that pops up.
For the Trigger, you want Entity > State. In the pop-up menu, choose the Matter button number that you identified (you may find a lot of entities, so use the search to narrow it down), and leave the other fields blank.
Close that, and you should see the trigger says When (your Matter button) changes state or any attribute. That just means we're going to check this automation whenever anything happens to that button. We'll add the switching logic next.
In the Then do section, select Add building block > Choose. Here's how it should look so far:
Expand the toggle for Option 1: No conditions, and click to add a new condition. Choose Entity > State. Similar to before, find your button entity. The Attribute should be Event type, and the State should be Pressed once (or pressed twice / held down, if you'd rather use those as triggers). Duration can be left blank.
Then close that and click Add action. Don't be tempted to choose Media Player, because that's the default media actions. Instead, search for "Music", and you should see a selection of Music Assistant: actions appear. Play Media is a generic option that will work for individual songs or playlists. In the resulting pop-up, the blue devices list lets you choose from your speakers. Although you can add multiple, they won't be synced unless they're in the same ecosystem (such as all Sonos speakers). The only other thing you need on this form is the Media URI.
For me, that's a Spotify playlist. You can either view the playlist ID by using the Spotify web interface, or from the player app, use the three dots menu -> Share -> Copy link to playlist . I got this URL:
https://open.spotify.com/playlist/6A9Jd5ZBG65lUvkmPggcrB?si=33d5d4d473aa460f
But don't paste that into Home Assistant. Instead, it needs to be in the format spotify://playlist/ID, where ID is the number that comes after /playlist/ in the URL above, and before the ?, which I've bolded in the example above.
Alternatively, if you navigate to the playlist from the Music Assistant dashboard, then scroll down and expand Provider details, you'll see it's listed there. Use the chain link icon to copy the exact link you need. Paste that into the Media URI field, and close the dialog—everything else can be left as is.
You can add additional conditions for other button states, such as double and long press, or just save the automation and test it out. You should now have the playlist start playing on your chosen speaker when you press the button. Here's it looks for me. Once you hit save, you might see your actions disappear. Don't worry, you can expand Option 1 to view them again.
As a final note, I'll mention that adding this automation in Home Assistant doesn't override your ability to automate with that button elsewhere (or other buttons on the same device). You could hop back to Apple Home and have the same button turn on a light; both actions would run simultaneously. Only the event occurrence is shared between systems; not the automation sequence that comes after it.