should have mentioned I am running card_mod 3.5.0, so dont need the mod-card.
Everyone should still be using 3.4.4 now, and require the mod-card to modify badges.
the modification itself should be valid for 3.4.4 too…
also, I did quickly try to get the rgb() colors from the badge color (and prevent the hard-coded rgb there) using the relative value syntax rgb(from var(--badge-color) r g b / 1) function. (see CSS rgb() function)
I didnt manage to find the 100% correct syntax for that though. Which is too bad, as it would allow me to generalize the modification into a yaml anchor or include ![]()
fwiw, I did try this,
style:
ha-badge:
$: |
.badge {
background:
{% set perc = states(config.entity)|float(0) %}
{% set rgb = 'rgb(from var(--badge-color) r g b)' %}
{% set rgb6 = 'rgba(from var(--badge-color) r g b/ 0.6)' %}
{% set rgb2 = 'rgba(from var(--badge-color) r g b / 0.2)' %}
linear-gradient(to right, {{rgb}} 0%, {{rgb}} {{perc}}%,
{{rgb6}} {{perc}}%, {{rgb2}} 100%) !important;
}
replacing the opacity in the function directly
but that isnt the same thing, check the pairs of badges (with the first badge for each cartridge using the automated template, and the second badge using the hardcoded color)
Ive also tried to use the @ Sir_Goodenough template but it doesnt accept theme variables, so asked for that Feature here [FR] Use theme variable names in the name2rgb function · Issue #6 · SirGoodenough/Color-Multi-Tool · GitHub