I've been struggling for hours to create a card that shows the most recent event image from my cameras. Despite multiple approaches, I keep getting 404 errors.
What I'm Trying to Do
- Display the newest image from multiple event cameras (all with _event_image suffix)
- Use the authenticated URL that works when accessed directly
- Automatically update when new images arrive
What I've Tried
type: picture
image: >-
{% set newest = (states.image | selectattr('entity_id', 'match', '.*_event_image$') | sort(attribute='last_updated') | last) %}
http://LOCALIP:8123{{ state_attr(newest.entity_id, 'entity_picture') }}
tap_action:
action: none
The Problem
- The template generates URLs like: http://LOCALIP:8123/api/image_proxy/image.turklingel_event_image?token=abc123
- These URLs work when pasted directly in browser, but return 404 in the card
- The same happens with picture-entity cards
Additional Info
- Manual tests confirm the entities exist and have valid entity_picture attributes:
{{ state_attr('image.turklingel_event_image', 'entity_picture') }}
→ /api/image_proxy/image.turklingel_event_image?token=abc123 - Camera entities are properly formatted:
{{ states.image | selectattr('entity_id', 'match', '.*_event_image$') | map(attribute='entity_id') | list }}
→ ['image.turklingel_event_image', 'image.zaun_event_image', ...]
Questions
- Why would the same URL work in browser but not in the card?
- Is there a better way to display authenticated camera images?
- Could this be related to token expiration during rendering?
Any help would be greatly appreciated! I'm happy to provide more details about my setup.