can’t find this anywhere, so maybe not allowed/possible via card_mod:
How to set an entity_picture based on state
first made a customization to get the correct path in inspector.
homeassistant:
customize:
input_select.intercom_language:
entity_picture: /local/flags/nl.png
which then shows promising and seems rather straightforward in inspector
state-badge:
background-image: url(" etc etc ");
the actual path is showing the http address too, but I suppose that would be handled internally… (hope)
also class= " pointer "
so, next step to write the card mod:
- entity: input_select.intercom_language
card_mod:
style: |
state-badge {
background-image: url("/local/flags/nl.png");
}
and .pointer
too.
but that does exactly nothing and the default icon is showing in stead.
since these are my last 2 mods I need to completely take out custom-ui I hope someone can find a way to help me out.
would be an awesome addition to the ‘standard’ card_mods available
thanks for having a look
update
Progress:
- entity: input_select.intercom_language
card_mod:
style:
hui-generic-entity-row:
$: |
state-badge {
{% set flag = states(config.entity)|lower %}
background-image: url("/local/flags/{{flag}}.png");
}
makes the entity_picture show. Still shows the icon too, so need to set display: none there, or, would this work:
.: |
:host {
--card-mod-icon: none;
}
Yes its does!.
a bit more complex but it gets the job done. If anyone can spot a way to get the entity_picture there in a simpler way, please dont hold back! for now Im set.
Nice indeed:
- type: entities
title: Herlaad Integratie
card_mod: *header
entities:
- entity: input_select.integration
card_mod:
style:
hui-generic-entity-row:
$: |
state-badge {
{% set state = states(config.entity)|lower %}
{% set path = '/local/images/integrations/' %}
background-image:
{% if 'luftdaten' in state %} {% set img = 'luftdaten' %}
{% elif 'philips' in state %} {% set img = 'hue' %}
{% else %} {% set img = state %}
{% endif %}
url("{{path}}{{img}}.png");
}
.: |
:host {
--card-mod-icon: none;
}
- entity: script.reload_integration
action_name: Herlaad
![Nov-28-2023 13-25-46](https://community-assets.home-assistant.io/original/4X/f/e/3/fe3133653fdb2ce91f9f3487862983f9537160d6.gif)