Hi, I need help with a simple configuration. I want to use a sensor to populate the path/filename of an image to show on my dashboard. Picture entity card or otherwise.
The sensor I have publishes an TitleId: for example “0100B7C00933A000”. I want to show a image with the path media-source://media_source/local/Server/TitleID.jpg
That would then translate to media-source://media_source/local/Server/0100B7C00933A000.jpg, or what ever that sensor value is.
I have tried a bunch of options but no luck, templating and such. Because the syntax has changed from a lot of the previous examples, I don’t know how to make this happen.
I appreciate any help with this basic config.
Thanks!
# This concatenates the `media_content_id` string and sensor result in a template
media_content_id: "{{ 'media-source://media_source/local/your_media_directory/' ~ states('sensor.your_sensor_id') ~ '.jpg' }}"
# or, this inserts the template into the `media_content_id` string
media_content_id: "media-source://media_source/local/your_media_directory/{{ states('sensor.your_sensor_id') }}.jpg"
Maybe you should give us a full picture of what you’re trying to do so that we can help you better, my advice is useless with the context you gave after my answer… See Rusty’s post.
The sensor is a MQTT sensor with entity id sensor.nintendo_switch_k_current_game_title_id
and the directory is a mapped network share. media-source://media_source/local/Server/
The picture entity card can use media-source images (it’s there in the UI picker), but it doesn’t have the ability to use a templated ID.
A template image can generate a key from an ID, but I don’t believe template image have any access to media-source files, it can only generate a URL, and that will not have the appropriate authorization keys added.
So you might be stuck for the moment from the core side. It would probably be a good feature request to make though.
The closest you can get for now is to move all your images to the /www/ folder and reference them with template image.