Need help with appending entity_picture url attribute to ha url

Yes, it works, pretty cool. Thanks!

I put this in dash file. Important to put access_token and not token

art_spotify:
    widget_type: camera
    entity_picture: 'https://xxx.duckdns.org/api/camera_proxy/camera.spotify_cover?{{ states.camera.spotify_cover.attributes.access_token }}&api_password=xxx'
    refresh: 10
1 Like

Should this still be working with AppDaemon 3?

I have a camera that seems to be working well in Home Assistant.

My widget in HADashboard is defined as:

spotify_album_cover:
    widget_type: camerae28b87deea3d83b026d8aec9b0eb7c6847602c9e8549281&api_password=my_password
    entity_picture: 'http://my_dash_url:8123/api/camera_proxy/camera.spotify_album_cover?{{ states.camera.spotify_album_cover.attributes.access_token }}&api_password=my_password'
    refresh: 10

But, I don’t think HADashboard can access that state value? Because, the image appears broken and in my console it seems to be trying to access the url without any kind of replacement:

http://my_dash_url:8123/api/camera_proxy/camera.spotify_album_cover?{{%20states.camera.spotify_album_cover.attributes.access_token%20}}&api_password=my_password&time=1519592184

This is resulting in a 401. Anyone have any thoughts on what problem this might indicate?

widget type should be camera

Hi, I’ve been working through this thread for a couple days now and coming up short on getting this artwork to show. I’ve got a Google home device that i’d like to show the currently playing artwork for.

I can view the artwork in a browser with the url:
http://192.168.1.203:8123/api/media_player_proxy/media_player.living_room?token=5417501d7baa331934df2361a6572324d74e2d0cb97872fff221379622af49e7

My camera config is as follows:

camera:
  - platform: generic
    still_image_url: http://192.168.1.203:8123/media_player_proxy/media_player.living_room?{{ states.media_player.living_room.attributes.token}}

I’ve tried it both with the token attribute and entity_picture attribute referenced by shire210 above.

I only ever get the same Generic Camera(Image not available) entry in the front end as witno above.

My Dashboard config is as follows:

media_art:
    widget_type: camera
    entity_picture: http://192.168.1.203:8123/api/camera_proxy/camera.generic_camera?token={{ states.media_player.living_room.attributes.access_token }}&api_password=supersecret
    refresh: 10

Here is the media player entity info in the front end:

I set my log level to debug, but the only messages I ever get are like these:
2018-04-07 14:42:16 INFO (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy/camera.generic_camera to 192.168.1.218 (auth: True)
2018-04-07 14:42:22 INFO (MainThread) [homeassistant.components.http.view] Serving /api/camera_proxy_stream/camera.generic_camera to 192.168.1.218 (auth: True)
2018-04-07 14:42:47 DEBUG (MainThread) [homeassistant.components.camera] Stream closed by frontend.

I’m a bit stuck, as I feel like I’ve tried all the different methods in this thread and nothing changes. Any help would be appreciated.

first things first.
make sure that the generic camera in HA is working and that its really called camera.generic_camera.
so find that camera in HA and see if it changes the picture.
if not then you have a problem in your HA config.

if it is working correct in HA you can go to step 2.

http://192.168.1.203:8123:8123/api/camera_proxy/camera.generic_camera?token={{ states.media_player.living_room.attributes.access_token }}&api_password=supersecret

this wont work in a dashboard, because a dashboard doesnt know templates.
so you could try:

http://192.168.1.203:8123:8123/api/camera_proxy/camera.generic_camera?api_password=supersecret

last remark: if you present yaml then you need to present it as a codeblock, if you dont, noone can read the yaml.

Thanks for the tips, I’ve edited my original post for the code blocks.
My HA camera is definitely not working correctly, but the camera.generic_camera is correct.

But when I use the url in the browser to view the camera directly, I get an all black page with a square in the middle (still in new member status, can only upload one pic at a time, but there’s not much to see).

And from the HA overview page for the camera when I click on it I get a broken image icon. I assume this means that my definition in configuration.yaml is incorrect, but I can’t figure out how it’s wrong based on the other posts that are working.

I gave up since all the tips they gave me were not working , so my advice is to… give up,

at least we know where the problem is.
its in the configuration.yaml

the first thing now to check if the token changes with every picture and if you can view the picture without the token.
if you need the token to view the picture and/or its constantly changing its gonna be hard but not impossible.
first off all you have this:

still_image_url: http://192.168.1.203:8123/media_player_proxy/media_player.living_room?{{ states.media_player.living_room.attributes.token}}

as url. but that will never work because you dont set the token there.
it should at least be:

still_image_url: http://192.168.1.203:8123/media_player_proxy/media_player.living_room?token={{ states.media_player.living_room.attributes.token}}

that could get your cam to work in HA.

Thank you! I’ve gotten it working. I was missing 2 pieces:
I was missing:
?token= before the template

and my original still_image_url was missing the api from the path, ie the working url is:
still_image_url: http://192.168.1.203:8123/api/media_player_proxy/media_player.living_room?token={{ states.media_player.living_room.attributes.token }}

Then this is my dashboard item config, and it would indeed seem that appdaemon understands the templating

media_art:
    widget_type: camera
    entity_picture: http://192.168.1.203:8123/api/camera_proxy/camera.generic_camera?token={{ states.media_player.living_room.attributes.access_token }}&api_password=ImNotTellingYouThat
    refresh: 10

For reference for anyone searching this later, I’m using a raspbian manual installation.

1 Like

so after a whole lot of messing around with this, I finally got it working for my setup so I thought I’d share what I did.

I ended up completely bypassing the generic camera aspect and went directly from the dashboard to my media player entity. The only thing I needed to add was in the dashboard config itself, mine looks like this:

media_art:
    widget_type: camera
    entity_picture: https://xxx.xxx.xxx:8123/api/media_player_proxy/media_player.spotify?token={{ states.media_player.spotify.attributes.token }}&api_password=xxxxxx

Obviously this is for spotify, not entirely sure if it will work for other players

token={{ states.media_player.spotify.attributes.token }}&

this part you can lose because the dashboard doesnt know templates.
so it seems that you dont need the token.

Hey Guys,

Great thread!

Has anyone got the generic camera working with a iTunes media player?

I can browser the iTunes album art with the url but can’t get it to display in the HA.

Any thoughts?

Thanks,

Stu

Ok, figured out my problem and posting which hopefully can help others. I needed to add my HA password to the HA config string

camera:
  - platform: generic
    still_image_url: 'http://xx.xx.xx.xx:8123/api/media_player_proxy/media_player.itunes?=token{{ states.media_player.itunes.attributes.token }}&api_password=ivegotasecret'

Cheers,

Stu

Had the same problem. The problem was that some code posted here was missing the ’ before http://…
It was at the end of the url though so that was the reason it didnt’t work.
Maybe somebody copy pasted the code for the configuration.yaml and forgot to add that little ’ in front of the URL.

And btw the token is unnecessary. Just add your password in the .dash file.

Working code:

media_player_picture:
widget_type: iframe
refresh: 1
frame_style: “”
background-size: contain
img_list:
- https://ip-address/api/media_player_proxy/media_player.spotify ?api_password=yourpassword

It updates instant and no caching problems. The token is only necessary if you want to access the link without your password.

@chris1
In your code, between spotfiy and ?api(…) is there a space or something else?
And maybe it is a dumb question, but what is the api-password? The pw for home assistant or spotify?

no space or anything else should be there
api password is the password set in home assistant.

Unfortunately, i can’t get it working. Here is my config.

media_player_picture:
widget_type: iframe
refresh: 1
frame_style: “”
background-size: contain
img_list:
  - https://192.168.0.130/api/media_player_proxy/media_player.spotify?api_password=myhttphomeassistantpw

Here is my appdaemon config, if needed

secrets: /config/secrets.yaml
log:
  logfile: STDOUT
  errorfile: STDERR
appdaemon:
  threads: 10
  app_dir: /config/appdaemon/apps
  plugins:
    HASS:
      type: hass
      ha_url: http://hassio/homeassistant
      ha_key: a20cbe36943b43efa0e611b9f412885d
hadashboard:
  dash_url: http://192.168.0.130:5050
  dash_dir: /config/appdaemon/dashboards

If it is relevant, i’m using hassio and have the duckdns + letsencrypt-addon installed.
I tried the ha_url from the appdaemon.yaml in combination with the key and also changing https to http.
But every time i see the iframe, but no picture is displayed :frowning:
does anyone know why it is not working? Thanks in advance!

first of all.
ha_key in appdaemon.yaml is you http homeassistant pasword.
so if that is your correct pw, then please remove and change.

secondly, in img_list you should use the same url as your ha_url
so
http://hassio/homeassistant/api/media_player_proxy/media_player.spotify?api_password=myhttphomeassistantpw

that is when you can use that url in your browser to go to HA. if you cant reach HA with:
http://hassio/homeassistant then your dashboard shouldnt be working at all.

1 Like

Thanks for your fast reply!

Yes, it was my pw, but i changed several numbers before posting.
By trial and error i found out, that in my case this img_link is working

https://hassio.local:8123/api/media_player_proxy/media_player.spotify?api_password=my_ha_pw
1 Like