Do you remember these two videos where I explained how you can set up this awesome Radio and Spotify Player in Home Assistant? Many of you asked me if it was possible to switch between physical Smart Speakers using this media player. It’s not possible by default, but I found a way so that you can control all your Smart Speakers using this media player! This is so great! Now you can control all your Smart Speakers in your house while you only see one Media Player on your dashboard! Let’s do this!
⭐⭐⭐ NOTE: ⭐⭐⭐
This article accompanies a YouTube video. I wrote it for people who would rather read than watch a video. In order to keep doing this, I would like to ask you to also check out the video, leave a comment under the video, give the video a thumbs up and subscribe to my YouTube channel. This means that the video is offered more often to new visitors so that they also stay informed of the latest Home Assistant tutorials.
Thank you for your support!
A lot of you implemented this Media Player in your own dashboard after I released these two videos. If you didn’t implement them already, check these videos out. They make it possible to control your Smart Speakers with this awesome media player. The media player can play radio streams and Spotify streams and works really great, but there was one thing that did not work. It was not possible to switch between physical Smart Speakers within the Media Player. Now, I found a workaround for this, so that you can show one media player on your dashboard and control all your Smart Speakers in your house with it. I must say, I applied a little trick here, but once you’ve set it up, it works great! And during the process, I updated the scripts so that they are even better to maintain than before.
You can follow along with this tutorial and type in the code yourself, or you can download the code that I’ve used in this video from the download link in the description below. This will save you time and frustration and you sponsor me so that I can keep creating these videos for you.
We are going to implement the following things in this Home Assistant tutorial:
- Create a dropdown helper with all our Smart Speakers in it.
- Create a media player for each Smart Speaker in our house.
- Show the Smart Speaker of our choice based on what we select in the dropdown helper.
Set up the Dropdown helper
Let’s start with setting up the dropdown helper.
Go to Settings, Go to Devices and Services, Go to the Helpers tab. Click create helper, click dropdown helper. Give your helper a name.
Icon radio maybe, and now add the options. My first option is Harman Kardon. My second option is Nest Mini Office, and my third option is Nest Hub. Create, and now the drop down helper is created.
Now that we’ve created our dropdown helper, we can start building a dashboard view with our media player. Check these two videos about how you can set the media player up first. You can also follow along in this tutorial, but I will not explain in detail how you can set up the media player itself. I do that in the other videos where I explain how the media player can be set up exactly. You can also download the media player code via the download link in the description of this video. Let’s add it to a dashboard now.
Add the media player to the dashboard
I already created the dashboard which is called tutorial. Let’s add a view. Call it media player. Save. Let’s add a card and I’m going to add the code for the media player here. Again how you build media player is in one of the other videos, so check them out. I’m just going to paste the code here. So I’m going to search for manual cards, paste the code and save it and now I have my media player on my dashboard.
I need your help!
You will be doing me a huge favor if you subscribe to my channel if you haven’t already. And, you help me a lot if you also give this video a thumbs up and leave a comment. This way, YouTube will present this video to new people and that will make the channel grow! In the description of the video, you will also find information about how you can sponsor me so that I can continue to make these tutorials for you.
The media player is now working for one of my Smart Speakers. But I want to control my other speakers as well. With this media player, you have to create a seperate media player for each Smart Speaker. Now, I think that if you have three Smart Speakers in your home, you do not want to show three media players on your dashboard. But you might want to have different playlists for each media player. So, what we are going to do, is that we are going to make use of the conditional card in Home Assistant to show the media player of your choice. This way, you will only see one media player at a time on your dashboard, and you can still control them all!
Add the dropdown field and conditional card to the dashboard
Let’s add a dropdown field to our dashboard and add a conditional card with the media player that we just created.
Go to the three dots over here. Click edit dashboards. Click add cards, and I’m going to select the entities card. Let’s remove these entities and the first entity is my drop down helper, which is Smart Speakers, and I’m going to save it over here. So now I have a drop down field here. The next card that I’m going to add is the conditional card, so I’m going to add cards. I’m going to search for conditional, and what I’m going to do is that I’m going to show the media player that is now on the screen based on the value of my drop down helper. So the entity is my drop down helper again. Smart Speakers and I’m going to say if the state is equal to Harman Kardon, which is our first value in our drop down helper, then I want to show a card.
So now we go to Card and we can add a card here. So again, we are going to add a manual card here. Search cards, manual, and we are going to paste the code of our media player in here, and save it. Now we are going to remove our original media player. So remove this one. Put this one on top. Click done.
The dropdown is on our dashboard and as you can see, if I select the Smart Speaker for the media player that we just added, the correct media player is shown. If I select a different Smart Speaker, no media player is shown because we did not add the media players for our other Smart Speakers to our dashboard yet. Let’s do that now by copying the existing conditional card and pointing to the other Smart Speakers within the new conditional cards.
Add the other two media players to our dashboard
Click on the three dots. Click edit dashboard, and now we are going to duplicate this card. Duplicate card. Now we’re going to change status equal Harman Kardon to Nest Mini Office.
Now we’re going to Card. We’re going to choose a different media player here. That is this one is my office media player, and now we are going to show code editor and we’re going to change media player Chromecast audio in Google Home 1277 and we do that on all places where we have Chromecast audio here. So let’s do that real quick.
Give the name Nest Mini office. Save this. Put it one place higher. Click done. Let’s check it if it works. Nest Mini Office. Now it shows the nest mini office player and now it shows the Harman Kardon player. Let’s do it again for the Nest Hub. Click on the three dots, Edit Dashboard. We’re going to duplicate this card again. Now we’re going to say Nest Hub. State is equal to Nest Hub. Go to card. We select the Nest Hub here.
We go again to show code editor. and we’re going to replace everywhere where we have Google Home in Google Nest Hub. Let’s do that real quick.
And give it a title Nest Hub. Save this, put it to one place higher, and what I can also do is show everything in one column because I have the layout card installed in HACS. So I’m going to click on this pencil, and I’m going to choose for view type vertical layout card. Save. Now I click done and now I can switch between the three different media players and I only see one media player on my screen.
If you don’t want to type the code from the screen, you can download the code that I’ve created for this video via the ko-fi link in the description below. With this, you sponsor me, and make it possible for me to keep creating these videos for you.
We’ve created a way to select different Smart Speakers in our house now using the conditional card and the select helper. If you want to make it even fancier, you can use buttons to switch between media players as well, but I will leave that up to you.
I want to thank everyone who has supported me in making these videos and tutorials so far. I could never have done this without you. Thank you! You can support me through Patreon, Ko-Fi, or by joining my channel. If you also want to support me, look in the description of this video for the links. With that, you make it possible that I can continue to make these videos for you.
Oh, don’t forget to give this video a thumbs up, subscribe to my channel, and hit the notification bell.
I will see you soon!