trying to create a conditional badge, and it should be added to an existing card-mod. Here, display: none is suggested by Troon, but I canāt get it right just yet.
- entity: sensor.state_badge
card_mod:
style: |
:host {
display: {% if config.entity is none %}none{%endif%}
}
ha-state-label-badge:
$:
ha-label-badge:
$: |
.badge-container .label-badge {
/* Top circle of the Badge (State) */
border-style: dashed;
border-color: blue;
color: grey;
background-color: yellow;
}
/* Label of the Badge (Unit) */
.badge-container .label-badge .label span {
border-style: dotted;
border-color: pink;
color: red;
background-color: green;
}
/* Below the Badge (Name) */
.title {
color: orange;
}
So I have two challenges here:
on config.entity: the config.entity is none template doesnt work, (while a test in dev tools does work) tried config.entity.entity_id etc. if not config.entity which should be valid, same effect: Keep getting
how to combine the display: none template with the other card_mod config settingsā¦
ā¦ pff now thats a bit of a surprise. I mean, not that these 2 templates do the same. of course they do. but the fact we can not use config.entity, and can not use is none, but need to use the states() of the config.entity, and need to check for 'unknown'
yes, thats what I wrote here, and as state there, it seems to work just fine. Have just tested it with this full card-mod, and can confirm once more that is shows when the existence check is positive. (the condition isnāt met, iow the states(config.entity) != 'unknown'
yes, of course I understand that, but thatās checking for the states state (as in state of the entity), while I was trying to check for the state (as in entity) itself
first check if the entity itself exists, then return an attributes of that entity
seems we should be able to do that with config.entity, unless thereās something in card-mod preventing that.
Well, youāve pointed me to a solution, to thanks again! Hope Thomas will have a look at the issue and see if things can be simplifiedā¦
now you lost meā¦ I thought you wanted an else clause? what would you suggest in this case then?
building on this, I tried the same mod on a button-card in the view, but that doesnāt work. It simply shows a button, with all style settings, but without a working entityā¦