Need help with appending entity_picture url attribute to ha url

This works for the changing token.

  - platform: generic
    name: Bedroom Sonos
    still_image_url: 'https://xx.duckdns.org/api/media_player_proxy/media_player.bedroom?{{ states.media_player.bedroom.attributes.token }}'

its that token. @witno Try what I just posted in this link…hint hint nudge nudge @rene LOL

also make sure when you put that url together it doesnt add anything when you hit enter. I use a mac and chrome and everything i put those urls together it slides an unwelcomed /index on me. i forget. i get mad. i do it again anyway.

Let me know if this helps

1 Like

can you share your code of the media player dashboard?

what are you looking for? how to get the picture? theres a lot of components on there

I just finished figuring out how to keep the pic updated based on what im doing. if im listening to music i get the entity pic of what im watching is displayed and if im watching tv the pic of what im watching is displayed. and the volume stays true no matter where the volume is changed. you want those two things? the buttons are scrtipts that call a playlist or station on my sonos

same for me

if possible all, so I will getthe bits and pieces I will use

no problem. ill post in a couple, im on a work call right now.

it’s working, only problem is when there is no picture (the media_player is off) … maybe possible to put a picture that nothing is playing?

Did you ever get to see that pic using the url? you need to solve that problem first

yes solved, it was nothing because the media_player was off. I wish that when the media_player has no picture that we could put in the dashboard a predefined picture (like nothing is playing)

Hats what I just finished. If plex is playing it takes that pic priority 1. Sonos priory’s 2 if it’s off it uses a standard image. I’m almost done

Ohh very cool.

BTW the token is not needed

Duh. Still not getting it working here. I can paste the
… entity_picture: /api/media_player_proxy/media_player.spotify?token=d3ca78b8d7310bb7ce82d3fb6eb9c536b6765eba25a5f2925ed2618c09da73ef&cache=3dcc718b563e0c4c

url in the browser and get album art, however the
http://10.0.0.27:8123//api/camera_proxy/camera.generic_camera?

is a 404

The full url with token:
http://10.0.0.27:8123/api/camera_proxy/camera.generic_camera?token=90390cb82a1c15fa8f3516a177340dd8774dd6b322744905b75cd6ded36cd30d

ERR_INVALID_RESPONSE

Ive found that the token is not needed sometimes. but thats not good, i dont want it to work sometimes. So I added the token. Here are a few things that should help: *I use sonos, but Im sure this should work with other media players too.

**Get currently playing info:**
- platform: template
  sensors:
    lr_playing:
      value_template: ' {{states.media_player.living_room.attributes.media_title}}<br />{{states.media_player.living_room.attributes.media_artist}} '

**get current volume level**
- platform: template
  sensors:
    living_room_vol:
      value_template: "{{ states.media_player.living_room.attributes.volume_level }}"
      friendly_name: Living Room Volume

**this is the old one. this just pulls the current pic of whats playing:**
- platform: template
  sensors:
    mediapic_bed:
      value_template: https://xxx.xxx.xxx/api/media_player_proxy/media_player.bedroom?{{ states.media_player.bedroom.attributes.token }}
      friendly_name: Bedroom Now Playing

**This is part of the code that I use to say what picture it needs.  * i still need to clean it up on my side**
- platform: template
  sensors:
    lrtest:
      value_template: >
        {% if is_state('media_player.plex_living_room', 'playing') %}
          Plex
        {% elif is_state('media_player.living_room', 'playing') %}
          Music
        {% endif %}

- platform: template
  sensors:
    lrtoomuch:
      friendly_name: "LR URL"
      value_template: >-
        {% if is_state('sensor.lrtest', 'Plex') %}
          https://xxx.xxx.xxx/api/media_player_proxy/media_player.plex_living_room?{{ states.media_player.plex_living_room.attributes.token }}
        {% elif is_state('sensor.lrtest', 'Music') %}
          https://xxx.xxx.xxx/api/media_player_proxy/media_player.living_room?{{ states.media_player.living_room.attributes.token }}
        {% endif %}

this is the camera for the entity pic:
  - platform: generic
    name: Living Room Playing
    still_image_url: "{{states('sensor.lrtoomuch')}}"

This changes the volume based on me moving the slider
- alias: Sonos Living Room Volume
  trigger:
    - platform: state
      entity_id: input_number.sonos_living_room_volume
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.living_room
        volume_level: '{{ trigger.to_state.state }}'

This moves the slider if i change the volume elsewhere:

- alias: living room vol set input number
  trigger:
    platform: state
    entity_id: sensor.living_room_vol
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.sonos_living_room_volume
      value: "{{ states.sensor.living_room_vol.state | float }}"

this is a script for playing a favorite:
oldrap:
  alias: "2k Rap"
  sequence:
    - service: media_player.sonos_join
      data:
        master: media_player.living_room
      entity_id:
        - media_player.basement
        - media_player.bedroom
        - media_player.living_room
    - service: media_player.volume_set
      data:
        entity_id:
          - media_player.basement
          - media_player.bedroom
          - media_player.living_room
        volume_level: "0.4"
    - service: media_player.select_source
      data_template:
        entity_id:
          - media_player.basement
          - media_player.bedroom
          - media_player.living_room
        source: '2K Hip-Hop'

**inputnumber**
sonos_living_room_volume:
  name: Living Room Volume
  initial: 0.3
  min: 0.0
  max: 1.0
  step: 0.1
1 Like

couple examples…
I need to redo these too. re layout and clean it up

1 Like

Let me know if you have any questions. Or if you get stuck.

@witno - here you go. This will display a photo or whatever you want when the media players are inactive. I have a web server I use that just gets a photo locally. I believe home assistant has a web server built in thats easy to use, I just havent ever had too. im sure a quick search would get you an answer though.

- platform: template
  sensors:
    lrtoomuch:
      friendly_name: "LR URL"
      value_template: >-
        {% if is_state('sensor.lrtest', 'Plex') %}
          https://xxx.xxx.xxx/api/media_player_proxy/media_player.plex_living_room?{{ states.media_player.plex_living_room.attributes.token }}
        {% elif is_state('sensor.lrtest', 'Music') %}
          https://xxx.xxx.xxx/api/media_player_proxy/media_player.living_room?{{ states.media_player.living_room.attributes.token }}
        {%- else -%}
          http://web/3d_lion.png
        {% endif %}

Well I lied earlier, I was having some problems when tv was playing since it still uses my sonos and they show as playing. Ive tested this pretty good so try it out and let me know if you have any issues.

- platform: template
  sensors:
    lrtest:
      value_template: >
        {% if is_state('media_player.living_room_atv', 'playing') %}
          ATV
        {% elif is_state('media_player.plex_living_room', 'playing') %}
          Plex
        {% elif is_state('media_player.living_room', 'playing') %}
          Music
        {% else %}
          Off
        {% endif %}

- platform: template
  sensors:
    lrtoomuch:
      friendly_name: "LR URL"
      value_template: >-
        {% if is_state('sensor.lrtest', 'Plex') %}
          https://xxx.xxx.xxx/api/media_player_proxy/media_player.plex_living_room?{{ states.media_player.plex_living_room.attributes.token }}
        {% elif is_state('sensor.lrtest', 'ATV') %}
          https://xxx.xxx.xxx/api/media_player_proxy/media_player.living_room_atv?{{ states.media_player.living_room_atv.attributes.token }}
        {% elif is_state('sensor.lrtest', 'Music') and states.media_player.living_room.attributes.source == "TV" %}
          http://web/blue.jpg
        {% elif is_state('sensor.lrtest', 'Music') %}
          https://xxx.xxx.xxx/api/media_player_proxy/media_player.living_room?{{ states.media_player.living_room.attributes.token }}
        {% elif is_state('sensor.lrtest', 'Off') %}
          http://web/blue.jpg
        {% endif %}
1 Like