you can also create a template sensor, and use that to template your colors in card mod.
Personally I dont use the dark and light modes theme functionality.
My theme either have a dark tonality or a lighter tonality. The darker ones have names that are searched for in this template:
{{states('input_select.theme') is
search('ight|Dark|Matrix',ignorecase=True)}}
so what this does is check which theme is selected, and whether it contains a string in the theme name (Midnight, Dark red, Dark orange, etc etc)
if yes, than the boolean turns true
based in that boolean state you can do what ever you want in card-mod
card_mod:
style: |
ha-card {
box-shadow: none;
background:
{% set dark = is_state('binary_sensor.donker_thema','on') %}
{% if not dark %} var(--ha-color)
{% endif %};
}
works perfectly, and no issue in Safari
also I card-mod theme:
/* Set the toolbar background. */
.header, .toolbar {
background: {% if kerst %} url('/local/wallpapers/snow.mp4')
{% elif donker_thema %}
radial-gradient(var(--primary-color),var(--card-background-color))
{% else %} var(--primary-color)
{% endif %};
color: var(--app-header-text-color)';
}
or get really crafty with:
map-background:
card-mod-theme: map-background
<<: *card-mod-card-yaml
card-mod-view: |
/*vertical-layout {
{% set dark = is_state('binary_sensor.donker_thema','on') %}
{% set flt =
'invert(.9) hue-rotate(170deg) brightness(1.5) contrast(1.2) saturate(.3)' %};
background: center/cover no-repeat url('/local/wallpapers/map.png') fixed;
filter: {{flt if not dark else 'none'}};
}*/
vertical-layout {
background:
{% set dark = is_state('binary_sensor.donker_thema','on') %}
{% set extension = '_dark' if dark else '' %}
center/cover no-repeat url('/local/wallpapers/map{{extension}}.png') fixed;
}
hui-sections-view {
background:
{% set dark = is_state('binary_sensor.donker_thema','on') %}
{% set extension = '_dark' if dark else '' %}
center/cover no-repeat url('/local/wallpapers/map{{extension}}.png') fixed;
}
but the latter is truly card-mod themeā¦ sorry
back on topic, in the themes file I did add this to my dark themes:
<<: &dark-theme
# https://github.com/home-assistant/frontend/blob/b83be385141a6d4513afc4848902745bcc31054f/src/components/map/ha-map.ts#L559
# https://github.com/home-assistant/frontend/blob/b83be385141a6d4513afc4848902745bcc31054f/src/resources/styles-data.ts#L54
map-filter: 'invert(.9) hue-rotate(170deg) brightness(1.5) contrast(1.2) saturate(.3)'
and that sets the nice dark background on the maps in my dark themes and not have them blind my eyes
thats the reason I have that particular card-mod theme section commented, itās just in my plain theme file