Media_player.template

Hi again, it seems that amp does not support JSON API or the ssh but only uses the ancient telnet method.

You will have to use the telnet integration.

You should be able to do what you want this way.
Maybe you might want to use buttons instead of switches.
However, If your amp asks for a password with telnet, I don’t know how the telnet integration supports passwords.

Hi @Sennevds,

I just realized I’m getting this error in the log:

Log details (WARNING)

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:1607
First occurred: 5:12:52 PM (3 occurrences)
Last logged: 5:12:52 PM

* Entity media_player.receiver (<class 'custom_components.media_player_template.media_player.MediaPlayerTemplate'>) is using deprecated supported features values which will be removed in HA Core 2025.1. 
Instead it should use <MediaPlayerEntityFeature.PAUSE|SEEK|VOLUME_SET|VOLUME_MUTE|PREVIOUS_TRACK|NEXT_TRACK|TURN_ON|TURN_OFF|VOLUME_STEP|SELECT_SOURCE|STOP|PLAY|SELECT_SOUND_MODE: 89535>, 
please create a bug report at https://github.com/Sennevds/media_player.template/issues and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation

Apparently there already is an issue posted on the GitHub.
Have you abandoned the project or will you fix it at some point?

I have made a example universal media player and a template media player for a android device running the hass app:

- platform: universal
  unique_id: bluscream_phone
  name: "Bluscream's Phone"
  device_class: tv
  commands:
    turn_on:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: play
    turn_off:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: pause
    volume_set:
      service: notify.mobile_app_timos_handy
      data:
        message: command_volume_level
        data:
          media_stream: music_stream
          command: "{{ volume_level }}"
    volume_up:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: volume_up
    volume_down:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: volume_down
    volume_mute:
      service: notify.mobile_app_timos_handy
      data:
        message: "command_volume_level"
        data:
          media_stream: "music_stream"
          command: "{{0 if is_volume_muted else 15}}"
    media_play:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: play
    media_pause:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: pause
    media_stop:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: stop
    media_previous_track:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: previous
    media_next_track:
      service: notify.mobile_app_timos_handy
      data:
        message: command_media
        data:
          media_command: next
  attributes:
    state: sensor.timos_handy_media_session
    is_volume_muted: >
      {{ "on" if states('sensor.timos_handy_volume_level_music') == 0 else "off" }}
    volume_level: sensor.timos_handy_volume_level_music
    # source: media_player.receiver|source
    # source_list: media_player.receiver|source_list
- platform: media_player_template
  media_players:
    receiver:
      unique_id: bluscream_phone2
      friendly_name: "Bluscream's Phone 2"
      device_class: receiver
      # current_source_template: "{{ states('input_text.selected_source') }}"
      value_template: >
        {{ 'on' if is_state("sensor.timos_handy_media_session", "Playing") else 'off' }}
      turn_on:
        service: notify.mobile_app_timos_handy
        data:
          message: command_media
          data:
            media_command: play
      turn_off:
        service: notify.mobile_app_timos_handy
        data:
          message: command_media
          data:
            media_command: pause
      volume_up:
        service: notify.mobile_app_timos_handy
        data:
          message: command_media
          data:
            media_command: volume_up
      volume_down:
        service: notify.mobile_app_timos_handy
        data:
          message: command_media
          data:
            media_command: volume_down
      # inputs:
      #   source 1:
      #     service: input_boolean.turn_on
      #     data_template:
      #       entity_id: input_boolean.source_1
      #   source 2:
      #     service: input_boolean.turn_on
      #     data_template:
      #       entity_id: input_boolean.source_2
      set_volume:
        service: notify.mobile_app_timos_handy
        data:
          message: "command_volume_level"
          data:
            media_stream: "music_stream"
            command: "{{volume}}"
      mute:
        service: notify.mobile_app_timos_handy
        data:
          message: "command_volume_level"
          data:
            media_stream: "music_stream"
            command: "{{0 if is_muted else 15}}"
      current_is_muted_template: >
        {{ "on" if states('sensor.timos_handy_volume_level_music') == 0 else "off" }}
      # album_art_template: "{{ state_attr('sensor.timos_handy_media_session','title_com.bambuna.podcastaddict') }}"
      title_template: "{{ state_attr('sensor.timos_handy_media_session','title_com.bambuna.podcastaddict') }}"
      album_template: "{{ state_attr('sensor.timos_handy_media_session','album_com.bambuna.podcastaddict') }}"
      artist_template: "{{ state_attr('sensor.timos_handy_media_session','artist_com.bambuna.podcastaddict:') }}"

Please leave some feedback and also tell me how i can do it without knowing the app package name