(I’ve not added a template yet, which is easy and only a matter of replacing there. first you make sure to get the right target in the card_mod, and also result )
I mean, you’ve got to realize youre setting the mod to the card as a whole, and not the individual entities.
like this card’s background
type: entities
entities:
- entity: sun.sun
title: Set color on Sun state
card_mod:
style: |
ha-card {
background:
{{ 'red' if is_state('sun.sun','below_horizon') else 'orange'}};
}