Great! thank you so much.
Thanks! I implemented this to create an alexa_media_last_alexa so I can now use notify.alexa_media_last_called
- platform: universal
name: Last Alexa
state_template: >
{%- for group in states.media_player|groupby('state') -%}
{%- for entity in group.list -%}
{%- if is_state_attr(entity.entity_id, 'last_called', true) -%}
{{ entity.entity_id }}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
- service: notify.alexa_media_last_called
data:
message: Home Assistant has started
title: Home Assistant
data:
type: tts
Dear @Sennevds, my Media Player Template stoppped working after the last Home Assistant update. I would really appreciate it if you could you take a look at it.
Here is the relevant info from the log.
2022-02-04 05:37:30 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up media_player_template platform for media_player
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/media_player_template/media_player.py", line 157, in async_setup_platform
async_add_entities(await _async_create_entities(hass, config))
File "/config/custom_components/media_player_template/media_player.py", line 205, in _async_create_entities
MediaPlayerTemplate(
File "/config/custom_components/media_player_template/media_player.py", line 298, in __init__
super().__init__(
TypeError: __init__() missing 1 required positional argument: 'hass'
also
2022-02-04 05:36:52 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration media_player_template which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
Is there anyone else with the same problem?
Did you update to the latest version: Release Add support for Home Assistant >= 2022.2 · Sennevds/media_player.template (github.com)
Awesome, now it works.
I was able to update it in HACS.
Thanks a lot.
Hello, thank you very much for the software
I’m using the system to make a custom shairport media player, but I’m having a problem with the media_image_url_template
. The artwork is passed via the metadata to the server and it’s kept on the local server, I have a script that updates the image every time the song changes, the way I conected the image to HA is with a camera card and local file. From there I get the API for the image and feed it to the media player.
The problem is that the media player caches the image it get feed the first time and it doesn’t change it. So even if I change the song, because of the fact that the URL is static it doesn’t change the image.
There is any way to point the media_image_url_template
to a local file? In case that is not possible maybe force for reloading the URL?
P.S. Sorry for my bad english
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 :
- I play a media like this :
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 ?
- Can you use TTS with the 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:
- playing
- paused
- idle
- off
- on
- true
- false
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