I can not get it to display the next and previous buttons as well.
Also, I can not get the progress/seek bar as well for some reason, even though I had defined the current_position and media_duration. Also, how can I implement the playmedia button that lets you play a media from home assistant, as it could be seen on the chrome cast player image below?
So, I have 3 problems: next/previous, progress bar, play media.
I would appreciate any help with this, however, I think there has to be something with the code. maybe there is something going on with using it with a Chromecast player since this is very similar to Jokerigno’s problem.
top player is template and bottom is Chromecast
I also have everything else working fine, set volume, mute, inputs, sound modes, on/off…
I’m actually using the media_player.template as an interface for my esphome rs232 controller for my sony avr. nice thing is that I can also use media_player.template to expose it to google home so I can control all the settings with voice using a google home mini.
The trick with using it with google is to make it recognize the player as a set-top box or an AVR. I believe google uses AI to determine what type it is from the device name since I think there is no way to specify the device type.
Google home device types are explained here
here is how the same player can have different device types in google home:
here is my config:
media_player:
- platform: media_player_template
media_players:
receiver:
friendly_name: "Audio-Video Receiver"
device_class: receiver
current_source_template: "{{ states('sensor.avr_source') }}"
value_template: >
{% if is_state("switch.avr_power", "on") -%}
on
{%- else -%}
off
{%- endif %}
turn_on:
service: switch.turn_on
data_template:
entity_id: switch.avr_on
turn_off:
service: switch.turn_on
data_template:
entity_id: switch.avr_off
volume_up:
service: switch.turn_on
data_template:
entity_id: switch.avr_volume_up
volume_down:
service: switch.turn_on
data_template:
entity_id: switch.avr_volume_down
play:
service: media_player.media_play
data_template:
entity_id: media_player.str_dn1080_2
pause:
service: media_player.media_pause
data_template:
entity_id: media_player.str_dn1080_2
stop:
service: media_player.media_stop
service_data:
entity_id: media_player.str_dn1080_2
next:
service: media_player.media_next_track
data_template:
entity_id: media_player.str_dn1080_2
previous:
service: media_player.media_previous_track
data_template:
entity_id: media_player.str_dn1080_2
sound_modes:
Direct:
service: switch.turn_on
data_template:
entity_id: switch.avr_soundfield_direct
Multi Channel Stereo:
service: switch.turn_on
data_template:
entity_id: switch.avr_soundfield_multi_channel_stereo
2 Channel Stereo:
service: switch.turn_on
data_template:
entity_id: switch.avr_soundfield_2_channel_stereo
Front Surround:
service: switch.turn_on
data_template:
entity_id: switch.avr_soundfield_front_surround
Neural:X:
service: switch.turn_on
data_template:
entity_id: switch.avr_soundfield_neural_x
Dolby Surround:
service: switch.turn_on
data_template:
entity_id: switch.avr_soundfield_dolby_surround
A.F.D.:
service: switch.turn_on
data_template:
entity_id: switch.avr_soundfield_a_f_d
inputs:
Turntable: # SA-CD/CD
service: switch.turn_on
data_template:
entity_id: switch.avr_source_sa_cd_cd
Computer: # VIDEO 1
service: switch.turn_on
data_template:
entity_id: switch.avr_source_video_1
Apple TV: # VIDEO 2
service: switch.turn_on
data_template:
entity_id: switch.avr_source_video_2
Cable TV: # SAT/CATV
service: switch.turn_on
data_template:
entity_id: switch.avr_source_sat_catv
TV:
service: switch.turn_on
data_template:
entity_id: switch.avr_source_tv
DVD: # BD/DVD
service: switch.turn_on
data_template:
entity_id: switch.avr_source_bd_dvd
GAME: # GAME
service: switch.turn_on
data_template:
entity_id: switch.avr_source_game
FM Tuner:
service: switch.turn_on
data_template:
entity_id: switch.avr_source_fm_tuner
USB:
service: switch.turn_on
data_template:
entity_id: switch.avr_source_usb
Bluetooth:
service: switch.turn_on
data_template:
entity_id: switch.avr_source_bluetooth
Home Network:
service: switch.turn_on
data_template:
entity_id: switch.avr_source_home_network
Music Service List:
service: switch.turn_on
data_template:
entity_id: switch.avr_source_music_service_list
#------------------------------------------------
set_volume:
service: number.set_value
data:
entity_id: number.avr_volume
#value: "{{((volume*74)|round|string|replace('.0', ''))|int}}"
value: "{% set vol = ((volume*100)|round|string|replace('.0', ''))|int -%}{% if vol > 74 %}74{% else %}{{vol}}{% endif %}"
#current_volume_template: "{{ states('number.avr_volume')|int/74 }}"
current_volume_template: "{{ states('number.avr_volume')|int/100 }}"
mute:
service: switch.toggle
data:
entity_id: switch.avr_mute
current_is_muted_template: >
{% if is_state("switch.avr_mute", "on") -%}
True
{%- else -%}
False
{%- endif %}
title_template: "{{ states.media_player.str_dn1080_2.attributes.media_title }}"
media_content_type_template: "{{ states.media_player.str_dn1080_2.attributes.media_content_type }}"
media_image_url_template: "{{ states.media_player.str_dn1080_2.attributes.entity_picture }}"
media_duration_template: "{{ states.media_player.str_dn1080_2.attributes.media_duration }}"
current_position_template: "{{ states.media_player.str_dn1080_2.attributes.media_position }}"
artist_template: "{{ states.media_player.str_dn1080_2.attributes.media_artist }}"
album_template: "{{ states.media_player.str_dn1080_2.attributes.media_album_name }}"
current_sound_mode_template: "{{ states('sensor.avr_sound_field') }}"
I hope this would be useful for someone.