I have an input select helper used to select 1 of 9 animals (don’t ask why!)
Each animal has an associated image stored in my /local/images folder.
My aim is to show the image of the select animal in a picture card.
I created a template sensor in my template.yaml as shown below:
- sensor:
- name: "Choosi Picture"
unique_id: sensor_choosi_picture
state: "{{ states('input_select.choosi_animals') }}"
attributes:
entity_picture: >
{% set base_url = '/local/images/choosi/' %}
{% set image_map = {
"Barbara": "Barbara.PNG",
"Barney": "Barney.PNG",
"Bianca": "Bianca.PNG",
"Billy": "Billy.PNG",
"Bee Kay": "Bee Kay.jpeg",
"Buddy": "Buddy.PNG",
"Gee Gee": "Gee Gee.PNG",
"Lola": "Lola.PNG",
"Rusty": "Rusty.PNG"
} %}
{% set default_image = 'default.jpg' %}
{% set selected_option = states('input_select.choosi_animals') %}
{% set image_filename = image_map.get(selected_option, default_image) %}
{{ base_url }}{{ image_filename }}
When I view sensor.choosi_picture in Developer Tools, I can see a thumbnail of the image and it changes when I change the input select option.
However, I cannot get the image to be displayed in a Picture Entity card using the yaml below:
show_state: false
show_name: true
camera_view: auto
type: picture-entity
entity: input_select.choosi_animals
grid_options:
columns: full
This will give a ‘No image source configured’ error.
Is there another way to do this?
I guess the same use case would be to show a HA users image in a picture card, rather than as an icon.