OK, I’ll try to help you get started on this.
First let’s start by creating your template media player.
You can start with something like this:
media_player:
- platform: media_player_template
media_players:
android_tv2:
unique_id: media_player.android_tv2
friendly_name: "Android TV2"
device_class: tv
Now let’s set how your new media player will obtain its power state (on/off/unavailable/etc):
value_template
is the parameter how your new media_player presents its power state.
value_template: "{{ states('media_player.android_tv_192_168_0_137') }}"
You see, if you type the above line (the part between double quotes) to: developer tools->template->template editor, you should be able to see in real time what value your android_tv_192_168_0_137 is providing. Also you are providing that to value_template
parameter of your new media_player. That’s what the above line does basically.
You can also type {{ states.media_player.android_tv_192_168_0_137}}
to see everything it provides. And you can get a specific value, such as for exampple the source attribute like this
{{states.media_player.android_tv_192_168_0_137.attributes.source}}
Since your new media player can correctly display the power state, now let’s set what your new player should do when you change the power setting:
You need to set the turn_on:
and turn_off:
actions of your new media_player.
turn_on and turn_off actions will be calling or triggering a service. You can check how the services work in: Developer tools-> services. Select a service and see what it will do there and test if your service action works.
In your case, you need to set the power of a media_player entity or device. In Developer tools-> services, look for something relevant;
Let’s try the service ‘Media player: Turn on’, select the service then choose your device or entitiy. After you do so, you can check if it works by clicking ‘call service’. If it works, click ‘go to yaml mode’.
You should be seeing something like:
service: media_player.turn_on
data: {}
target:
entity_id: media_player.android_tv_192_168_0_137
Let’s use that service for what your new template media_player will do for the turn_on action.
turn_on:
service: media_player.turn_on
data: {}
target:
entity_id: media_player.android_tv_192_168_0_137
Now do the same for turn_off.
so far we have:
media_player:
- platform: media_player_template
media_players:
android_tv2:
unique_id: media_player.android_tv2
friendly_name: "Android TV2"
device_class: tv
value_template: "{{ states('media_player.android_tv_192_168_0_137') }}"
turn_on:
service: media_player.turn_on
data: {}
target:
entity_id: media_player.android_tv_192_168_0_137
turn_off:
service: media_player.turn_off
data: {}
target:
entity_id: media_player.android_tv_192_168_0_137
You now have a media player that can receive and control power.
I believe you can now go through with all the other parts of the media player template configuration with this method.
Also, this thread has examples for all the parts you need.
Check this YouTube video for better understanding how templates work:
Home Assistant Templates - A Beginner’s Guide
Try to make your own configuration, checking each part step by step. Then ask about specific problems you might run into about a part of your configuration.
I hope this helps.