Hi @Sennevds ,
I have the following.
I can’t remember if it was like this before or if this is a new thing or if i’ve done something.
Is this normal? Is there a way to avoid this?
Hi @Sennevds ,
I have the following.
I can’t remember if it was like this before or if this is a new thing or if i’ve done something.
Is this normal? Is there a way to avoid this?
Add a unique_id to your yaml configuration. His custom integration supports it.
Hi, I’m working on a player based on esp8266, it is controlled with MQTT commands so I think that your component could allow to control it on Home Assistant
I have two little questions about your component :
MQTT topic: "my_mqtt_topic/play"
MQTT load: "http://url-to-the-mp3-file/file.mp3"
Any idea how to implement this in Media_player.template ?
Thanks for the sharing of your work !
Dear @Sennevds, I’m interested in this too, could you please provide an example to play something from a URL?
Play media would be something like this:
play_media:
service: mqtt.publish
data:
topic: "my_mqtt_topic/play"
payload: "{{media_id}}"
I think because I never tested this.
You have 2 parameters you can use in your service and that’s media_id and media_type.
TTS could work if you have an url to the message
Awesome, it’s working directly Thanks a lot for that !
For the moment I’ve made some ugly implementations to have the player status on ( I copy the status of another player I force it to “on”) but it’s working, including TTS !
Can I ask you some help again to implement the other functionalities ?
For now I have this :
media_players:
receiver:
friendly_name: MrDiyReceiver
device_class: receiver
value_template: "on"
play_media:
service: mqtt.publish
data:
topic: "diy/play"
payload: "{{media_id}}"
turn_on:
service: switch.turn_on
# data_template:
# entity_id: switch.receiver_on
turn_off:
service: mqtt.publish
data:
topic: "diy/stop"
volume_up:
service: mqtt.publish
data:
topic: "diy/volume"
payload: "+"
volume_down:
service: mqtt.publish
data:
topic: "diy/volume"
payload: "-"
set_volume:
service: mqtt.publish
data:
topic: "diy/volume"
payload: "{{volume}}"
mute:
service: mqtt.publish
data:
topic: "diy/volume"
payload: "0"
Stop and play are working as it should
The volume set works fine (it is perfect with mini media player because you can fix boundaries). But HA doesn’t know the current volume of the player. Is this component able to listen a mqtt topic to get the current value of the player ?
Do I have to create an input_boolean to get the status from MQTT ? My player send hist status like this :
topic : diy/LWT
payload : online
and also like this :
topic : diy/status
payload : idle / playing
May be I could get the status directly from MQTT without input_boolean ?
If you set the value_template to playing/idle you also get the the pause/play button. For the volume you will need to use the current_volume_template. You don’t need a input_boolean but you will need a sensor with the current status. The valid states for value_template are:
The advantage is that I can customize the firmware to get all the MQTT status I need.
But I’m too zero in value templating
I’m totally lost for the way to import MQTT data in a template value… sorry
I’ve got this for the moment, which is totally wrong…
- platform: media_player_template
media_players:
receiver:
friendly_name: MrDiyReceiver
device_class: receiver
value_template:
platform: mqtt
topic: diy/status
current_volume_template:
platform: mqtt
topic: diy/volume
play_media:
service: mqtt.publish
data:
topic: "diy/play"
payload: "{{media_id}}"
Edit: Similar problem in this issue, may be I should create a sensor to get the MQTT value and then set my media player template status with this sensor ?.. Look like useless sensors to me
You will need a sensor first and use that sensor for the media template. You’ll need to see the sensor as a helper. So it’s not useless.
Hello,
any news about this @schmurtz please?
could be nice to have a sensor.
"Text to speech has moved to the media browser. "
but in MediaBrowser i cant see the receiver create with media_player.template…
@Sennevds why please your
device_class: receiver
and not
device_class: media_player
and has no “entity_id:” section ?
Thanks
These are examples you can choose your own values. I think you can also give a entity_id with it if you want.
The whole mediabrowser thing was never implemented and I don’t have any need for it but if someone wants to try it I’m glad to review the PR on github
i had the “entity_id” section but it makes no difference, the receiver is not recognize in Media Browser.
hi…Can somone help me create a media player or merge two media players togther.
i have a android tv and it has two media player entities
-andriod_tv
and -android_tv_adb
what i actually want: I use android_tv_adb
as my front end in mini media player but this entity lacks attribute media_title
and also this don’t have a media seek (so no progress bar) option soo cant really control the media play location. soo i need to add these abilites and and other attributes from other android tv entity to this.
is their any way to do ?
Yes you can combine state attributes from various sources.
Let’s first understand the differences between -andriod_tv
and -android_tv_adb
?
Go to ‘developer tools’ → States and choose your player and copy their state attributes and paste here while the device is playing something. Do the same for both of your player devices.
The output should be something like the following:
volume_level: 0.25
is_volume_muted: false
media_content_id: spotify:track:3eSxXVN5ZpFYjIpIdzKhAX
media_content_type: music
media_duration: 377
media_position: 0.411
media_position_updated_at: '2022-09-12T07:55:31.215615+00:00'
media_title: Acid Turtle
media_artist: Robert Bobich
media_album_name: Aciiieeed! No. 28
app_id: CC32E753
app_name: Spotify
entity_picture_local: >-
/api/media_player_proxy/media_player.str_dn1080_2?token=11421a0258fff58045907f87baa0761dd5a94efbddf305e65d8057c9b2da3434&cache=8b3c81da07586665
device_class: speaker
entity_picture: https://i.scdn.co/image/ab67616d0000b273efd5f2e474511c69233d122c
friendly_name: STR-DN1080
supported_features: 152511
The above output is from my Audio Video Receiver’s chrome integration. In addition to the above stuff, I’ve also used entities and states from an EspHome device I made that controls the AVR. I’ve used both entities from EspHome device and entities from chrome integration to make my template player which looks like the following:
source_list:
- Apple TV
- Video 1
- DVD
- Cable TV
- Turntable
- Computer
- Game
- FM Tuner
- USB
- Bluetooth
- Home Network
- Music Service List
sound_mode_list:
- Direct
- Multi Channel Stereo
- 2 Channel Stereo
- Front Surround
- Neural:X
- Dolby Surround
- A.F.D.
volume_level: 0.18
is_volume_muted: false
media_content_type: music
media_duration: 377
media_position: 0.393
media_position_updated_at: '2022-09-12T09:11:44.644892+00:00'
media_title: Acid Turtle
media_artist: Robert Bobich
media_album_name: Aciiieeed! No. 28
source: Chromecast
sound_mode: Multi Channel Stereo
entity_picture_local: >-
/api/media_player_proxy/media_player.receiver?token=f7be31cac739be6e553bce28fada38f2f46e57f462c4f5a85e95fb2217374d08&cache=8b3c81da07586665
device_class: Set-top box
friendly_name: Sony Audio-Video Receiver
supported_features: 89533
hey thanks for responding @Mr.ToR . Below i have shared the state attrubites of both android_tv and android_tv_adb media players.
Output of media_player.android_tv
volume_level: 0.019999999552965164
is_volume_muted: false
media_content_id:
media_duration: 281.52
media_position: 0.707
media_position_updated_at: 2022-09-12T17:59:14.792282+00:00
media_title: Luis Fonsi - Despacito ft. Daddy Yankee
media_artist: Luis Fonsi
app_id: 2C6A6E3D
app_name: YouTube
entity_picture_local: null
friendly_name: Android TV
supported_features: 152511
Output of media_player.android_tv_192_168_0_137
source_list: com.google.android.inputmethod.latin, com.android.systemui, com.google.android.tv.remote.service, com.google.android.gms.persistent, com.android.providers.tv, com.google.process.gservices, com.xiaomi.android.tvsetup.partnercustomizer, com.google.android.tvrecommendations, com.mitv.tvhome.atv, YouTube, Google Cast, Android TV Launcher, com.google.android.katniss:interactor, com.google.android.partnersetup, com.miui.tv.analytics, com.googlecode.eyesfree.setorientation, com.google.android.gms, com.yablio.sendfilestotv, de.cyberdream.androidtv.notifications.google, SonyLIV, Play Store, com.google.process.gapps, android.process.media, com.android.vending:background, dex2oat
volume_level: 0.02
is_volume_muted: false
app_id: com.google.android.youtube.tv
app_name: YouTube
source: YouTube
adb_response: null
hdmi_input: null
entity_picture: /api/media_player_proxy/media_player.android_tv_192_168_0_137?token=3ead231ce92cdf211150aec37baf99c25ee18341579015f6c2c579a5f0cbbb43&cache=1663005651.919918
friendly_name: Android TV 192.168.0.137
supported_features: 23997
what i want to merge :
i want to have all the media_player.android_tv_192_168_0_137
attributes and in addition add few attributes of media_player.android_tv
reason: media_player.android_tv_192_168_0_137
does not allow to seek peek forward or backward and also it has no attribute to show what song is playing(media_title
)
hope you could help me get this …
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.
thanks for the response, i understand what you have explained but how do i add all the existing attributes of the media_player.android_tv_192_168_0_137
in custom template media player?
for example entity_picture
attribute ?
did you read https://github.com/Sennevds/media_player.template
Check the implemented features in media_player.template.
entity_picture
attribute is probably what your android device provides. As you can see from the examples, you can link it to an appropriate feature of the media_player.template.
Like I said, do not jump to the pictures. First get a simple media_player working and start adding features to it slowly. First get power to work, then add next/previous etc. Did you get a basic player working?
Did you check the documentation and this thread? There are multpile examples.
Which example are you trying or taking advantage of?
check post #64 on this thread for example.
I don’t think anyone would write you a template config for you.
However, people are pretty helpful here in general especially about helping one to learn how to do stuff, but you have to do the reading. Usually best help is just a pointer to a feature or some documentation.
I believe I gave you a very detailed and helpful outline to get you started.
First get yourself to be able to make the volume to work on your basic template media player for example. Follow my post about using a feature of the media_player.template and how you can assign values to it or howto get the template to control something with a service.
I noticed that this is marked as no longer maintained.
Is it still working ? Has anyone come across an alternative ?
The universal media player integration is … OK … but i cant seem to find a way to make it display an image.
I haven’t posted a update so github badge shows it as unmaintained. I still use it myself and it still works for me.