I need to follow up on this, as this is a tricky one no one could ever solve so far (itās been two years nowā¦):
Instead of having this:
created with this:
- entity: weather.dwd_weather
name: Wetter
tap_action:
action: navigate
navigation_path: temperatur-overview
icon: mdi:home
card_mod:
style:
ha-state-label-badge:
$:
ha-label-badge:
$: |
.badge-container .label-badge .value {
#color: #DF4C1E;
#--ha-label-badge-title-width: 60px;
}
.badge-container .label-badge {
border-radius: 20% !important;
}
.badge-container .label-badge .value::after {
content: "{{ state_attr(config.entity,'temperature') }} Ā°C";
background-color: var(--ha-label-badge-color, var(--primary-color));
color: var(--ha-label-badge-label-color, white);
border-radius: 1em;
padding: 9% 16% 8%;
font-weight: 500;
overflow: hidden;
position: absolute;
bottom: -1em;
left: -0.2em;
right: -0.2em;
line-height: 1.2em;
font-size: 0.5em;
}
.: |
:host {
{% set weather = states(config.entity) %}
{% set icon =
{
'clear-night':'mdi:weather-night',
'cloudy':'mdi:weather-cloudy',
'fog':'mdi:weather-fog',
'hail':'mdi:weather-hail',
'lightning':'mdi:weather-lightning',
'lightning-rainy':'mdi:weather-lightning-rainy',
'partlycloudy':'mdi:weather-partly-cloudy',
'pouring':'mdi:weather-pouring',
'rainy':'mdi:weather-rainy',
'snowy':'mdi:weather-snowy',
'snowy-rainy':'mdi:weather-snowy-rainy',
'sunny':'mdi:weather-sunny',
'windy':'mdi:weather-windy',
'windy-variant':'mdi:weather-windy-variant'
} %}
--card-mod-icon: {{ icon[weather] if weather in icon else 'mdi:home' }};
--label-badge-text-color: #df4c1e;
}
I want to have the sensorās attribute (temperature
) as label text and add a custom UoM text to the UoM field.
With
- entity: weather.dwd_weather
name: Wetter
tap_action:
action: navigate
navigation_path: temperatur-overview
icon: mdi:home
card_mod:
style:
ha-state-label-badge $:
ha-label-badge $: |
.badge-container .label-badge {
border-radius: 20% !important;
}
.badge-container .label-badge .value::after {
content: "{{ state_attr(config.entity,'temperature') }}";
--background-color: var(--ha-label-badge-color, var(--primary-color));
--color: var(--ha-label-badge-label-color, white);
--border-radius: 1em;
--padding: 9% 16% 8%;
--font-weight: 500;
--overflow: hidden;
--position: absolute;
--bottom: -1em;
--left: -0.2em;
--right: -0.2em;
--line-height: 1.2em;
--font-size: 0.5em;
}
.: |
ha-label-badge ha-state-icon {
display: none;
}
I get
where the OuM is clearly missing.
How can I show a custom UoM when the visible label text does not have one (because it is an attribute)?
The interesting thing is:
Once I add
background-color: var(--ha-label-badge-color, var(--primary-color));
color: var(--ha-label-badge-label-color, white);
border-radius: 1em;
padding: 9% 16% 8%;
font-weight: 500;
overflow: hidden;
position: absolute;
bottom: -1em;
left: -0.2em;
right: -0.2em;
line-height: 1.2em;
font-size: 0.5em;
to the .badge-container .label-badge .value::after
(commented out in above snippet)
I get this:
So now the label text is missing.
Why canāt I have both - label text from a sensorās attribute and a custom OuM text?
Somethingās missing here - and I feel like itās just a small thingā¦
Driving me nuts as I spent so much time already on this, without any success