I have a media player entity with sources.
I want to be able to control those sources with switches so that I can expose it to my Google Assistants and control the source by voice. I believe the best way to do this is with a switch template but being my first attempt with Home Assistant I have no clue how to do this.
It should be a switch that is on if the media player is on and the source is set to the one I define.
When the switch is turned off it will turn off the media player.
When the switch is turned on it will turn the media player on (if off) and then change the source.
Can someone please direct me on the best method of doing this?
@123 I just grabbed this example, it is not an attempt to get it working as I figured someone else would have done something similar in the past.
I don’t know if this is the best method. I simply want to be able to expose a switch to google assistant so i can say ‘Hey google, turn on the radio in the kitchen’ and it will turn on my Russound media player and switch to the proper source input.
Short answer is yes that is my goal to expose source switching to google assistant.
As this is my first attempt at creating something custom, other than following setup instructions (have ssl, reverse proxy, google assistant, google maps device tracking, russound, ecobee all setup).
I don’t have media_players to experiment with so I can’t test anything. There are community members here who are more experienced with media_players who can easily steer you in the right direction. Until they show up, you can tinker with this (untested) Template Switch. Obviously you’ll need to modify the entity names to match whatever represents your Russound system.
I added a delay of 2 seconds between turning the system on and changing its source. This may not be necessary; you’ll have to experiment with it.
Look at the source names as they’re presented in Developer Tools > States for media_player.kitchen. I used lowercase ‘tuner’ but it may actually be reported in propercase. As a general rule, refer to the States page when checking these names and not how they are presented in the Lovelace UI. The source of truth is the States page.
Quick question, being new to Home Assistant from OpenHAB is there a page that lists all the attributes of the components? The Media Player component page lists the services but not the attributes.
For a media_player, the list of all possible attributes is in its source code. However, the media_player attributes available to the specific platform one is using are shown in the States page.
For future reference, it is customary in this community that when someone provides you with information answering your question or solving your problem, that is considered to be the ‘Solution’. The source of the solution, is the Solution, not the copy of it.
Nevertheless, it’s a custom, not a rule, and you’re free to mark whichever post you want as being the Solution.
Good luck and welcome to the Home Assistant community.