How to change the text color to red if you were at home during working hours from 9 a.m. to 6 p.m.?
type: custom:logbook-card
entity: device_tracker.192_168_1_2
How to change the text color to red if you were at home during working hours from 9 a.m. to 6 p.m.?
type: custom:logbook-card
entity: device_tracker.192_168_1_2
Use Code Inspector to find out a correct selector.
Thatās my issue. I tried several but I donāt ever seem to see an effect on the front. If I manually select it and change it with the developer tools it works. Suggestions for what I may be doing wrong?
Not using this card. Are you using card-mod properly in general? Have you tried with standard cards? Have you checked1st post - link at the bottom?
hi again
i am trying to change the icons of the buttons of a media_player.template card
i have managed to change the size , spacing etc of the icons but i have not managed to change the actual icons.
what did work was to change the icon of the card itself (see below āmdi:kodiā) but not for the buttons
card:
type: media-control
entity: media_player.kodi_firetv
card_mod:
style: |
:host {
--card-mod-icon: mdi:kodi !important;
}
hui-marquee {
font-size: 1.6em !important;
}
ha-icon-button[action=turn_off] {
--mdc-icon-button-size: 90px !important;
--mdc-icon-size: 60px !important;
}
ha-icon-button[action=turn_on] {
--mdc-icon-button-size: 90px !important;
--mdc-icon-size: 60px !important;
}
ha-icon-button[action=media_previous_track] {
--mdc-icon-button-size: 90px !important;
--mdc-icon-size: 60px !important;
}
ha-icon-button[action=media_pause] {
--mdc-icon-button-size: 90px !important;
--mdc-icon-size: 60px !important;
}
ha-icon-button[action=media_next_track] {
--mdc-icon-button-size: 90px !important;
--mdc-icon-size: 60px !important;
}
i tried adding the --card-mod-icon to the buttons but that didnāt work.
any idea would be much appreciated.
this is what it looks like atm
the circled buttons i want to change icons for.
using code inspector i found this āpathā which allows me to to change the icons manually in the code but that ofc does not persist
User-defined config options - to be used inside card-mod:
Interesting & useful.
type: entities
entities:
- entity: sun.sun
my_color: red #user-defined config
card_mod: &ref_style
style: |
:host {
color: {{config.my_color}};
}
- entity: sun.sun
my_color: cyan
card_mod: *ref_style
Call a reusable card-mod code as an anchor or by āincludeā - and define settings as a part of āconfigā.
Ofc can be used with standard options as well (as it can with āconfig.entityā):
- type: history-graph
entities:
- entity: sensor.system_monitor_processor_use
hours_to_show: 24
card_mod: &ref_style
style: |
ha-card {
{% if config.hours_to_show < 12 -%}
{%- set COLOR = 'rgb(0,255,0)' -%}
{%- elif config.hours_to_show >= 12 and
config.hours_to_show <= 24 -%}
{%- set COLOR = 'rgb(255,0,0)' -%}
{%- else -%}
{%- set COLOR = 'rgb(255,255,0)' -%}
{%- endif -%}
--graph-color-1: {{COLOR}};
}
- type: history-graph
entities:
- entity: sensor.system_monitor_processor_use
hours_to_show: 6
card_mod: *ref_style
- type: history-graph
entities:
- entity: sensor.system_monitor_processor_use
hours_to_show: 32
card_mod: *ref_style
How can I set the font color for the secondary info of the default HA tile cards globally in my own theme-file?
Hello @Ildar_Gabdullin,
thx a lot for those examples. Iām struggling to combine two of examples you posted here: changes of the main entry and of secondary entries.
I have a card mod for the main entry, itās this one:
type: entities
show_header_toggle: false
entities:
- entity: climate.thermoschlazi
name: Schlafzimmer
secondary_info: false
tap_action:
action: more-info
double_tap_action:
action: toggle
card_mod:
style:
hui-generic-entity-row$: |
state-badge {
color: {{ iif(is_state('climate.thermoschlazi', 'off'), '', '#FFC107') }};
--card-mod-icon: {{iif(is_state('climate.thermoschlazi', 'off'), 'mdi:radiator-off', 'mdi:radiator') }};
}
.info.pointer .secondary
ha-relative-time {
display: {{ iif(is_state('climate.thermoschlazi', 'off') and not is_state('input_select.heizung', 'Aus'), '', none) }};
color: {{ iif(((now() - states.climate.thermoschlazi.last_changed).total_seconds() // 60) > 19, 'red', '') }};
}
type: custom:multiple-entity-row
show_state: false
entities:
- attribute: temperature
name: Target
unit: Ā°C
- attribute: current_temperature
name: Current
unit: Ā°C
styles:
width: 100px
- entity: switch.licht_schlazi
name: Licht
state_color: true
tap_action:
action: toggle
What I want to add is coloring of the 3rd child of the secondary entries so it changes the state color on switch state. Without the main entry mod this works for that:
type: entities
show_header_toggle: false
entities:
- type: custom:multiple-entity-row
entity: climate.thermoschlazi
name: Schlafzimmer
secondary_info: false
show_state: false
tap_action:
action: more-info
double_tap_action:
action: toggle
entities:
- entity: switch.licht_schlazi
name: Licht
state_color: true
tap_action:
action: toggle
card_mod:
style: |
.entities-row div.entity:nth-child(1) {
color: {{ iif(is_state('switch.licht_schlazi', 'off'), '', '#FFC107') }};
}
What i cannot figure out is how to integrate the 2nd style into the first one. Could you please help. thx
best regards,
Zavjah
As always: First post, link to Ildas examples/tutorials and there you will find an entry for combining such things. Or search for this in this thread and you will find the same question and same answer and even more examples a lot (!) of times.
Sometimes it is really faster and more helpful to do some search and see, how the others are doing it and if the same questions has been flying around again and again.
Example: The last same question has been answered just 2d/15 posts above.
Anyone willing to look at the below and tell me where I am going astray? Problem is the text color is not changing when then the background changes to yellow. The card is showing me the output of some of the FLUME sensors. The background color will change based on the # of gallons used, this is working, problem I am having is when it turns yellow I canāt read the numbers so I want the text color to change to black only when the background is yellow. this is all the code for ref. the Card Mod stuff is at the end, attempt 1 was this-
mode: horizontal
cards:
- type: custom:button-card
entity: sensor.flume_sensor_denmans_current_day
name: Today
icon: mdi:water
show_state: true
styles:
card:
- '--keep-background': 'true'
- filter: opacity(70%)
- height: 40px
icon:
- color: white
name:
- font-size: 12px
- color: white
- type: custom:button-card
entity: sensor.flume_sensor_denmans_current_week
name: This Week
icon: mdi:water
show_state: true
styles:
card:
- '--keep-background': 'true'
- filter: opacity(70%)
- height: 40px
icon:
- color: white
name:
- font-size: 12px
- color: white
- type: custom:button-card
entity: sensor.flume_sensor_denmans_current_month
name: This Month
icon: mdi:water
show_state: true
styles:
card:
- '--keep-background': 'true'
- filter: opacity(70%)
- height: 40px
icon:
- color: white
name:
- font-size: 12px
- color: white
card_mod:
style: |
ha-card {
{% set value = states('sensor.flume_sensor_denmans_current_month')|int %}
{% if value >= 0 and value <= 12000 %}
--ha-card-background: green;
{% elif value >= 12001 and value <= 15000 %}
--ha-card-background: yellow;
{% else %}
--ha-card-background: red;
{% endif %}
{% if value >= 12001 and value <= 15000 %}
color: black;
{% else %}
color: var(--accent-color);
{% endif %}
} ```
Attempt 2, Just the changed Card Mod stuff-
``` card_mod:
style: |
ha-card {
{% set value = states('sensor.flume_sensor_denmans_current_month')|int %}
{% if value >= 0 and value <= 12000 %}
--ha-card-background: green;
{% elif value >= 12001 and value <= 15000 %}
--ha-card-background: yellow;
{% else %}
--ha-card-background: red;
{% endif %}
{% if value >= 12001 and value <= 15000 %}
color: black;
{% endif %}
}
Atempt 3, also no go.
style: |
ha-card {
{% set value = states('sensor.flume_sensor_denmans_current_month')|int %}
{% if value >= 0 and value <= 12000 %}
--ha-card-background: green;
{% elif value >= 12001 and value <= 15000 %}
--ha-card-background: yellow;
{% else %}
--ha-card-background: red;
{% endif %}
}
.card-content {
color: var(--accent-color);
}
.card-content.yellow {
color: black;
}
Good morning!
Does anyone know how to add a shadow to the image in the weather card?
And: Can I reduce the spcing in between the Text and the temperture?
Thanky you, a lot, and all the best!
used someone code for a thermostat for a room, but it put a green bar below and I canāt remove it.
type: custom:stack-in-card
keep:
margin: false
box_shadow: false
background: false
cards:
Please post your code based off #11
Hi there,
Since I updated to 2024.02, some of the card_mod configurations are not being applied, in this case on the Tile card, mainly this one:
card_mod:
style:
.icon-container .icon$: |
.shape {
border-radius: 15px !important;
This should make the icon containers almost square, with a round of 15px at the corners but now they are all round. I suppose this is being ignored.
Someone have some pointers on how to solve this?
Thanks.
Pedro.
Hello everyone,
Iām currently using a dashboard that is made up of various custom cards. My goal for 2024 is to move the whole thing back a little more towards standard
And to explore the possibilities with the standard cards + Card_Mod where necessary.
I currently have some problems where I hope you can help me
I would like to use a tile card and display only one icon. The Problem is the GAP for the Name stays there.
- type: tile
icon: mdi:home-outline
entity: zone.home
hide_state: true
show_entity_picture: false
vertical: false
card_mod:
style:
ha-tile-info$: |
.primary {
visibility: hidden;
}
Is there a better way to achieve my goal?
Unfortunately, the problem here is that Iām missing the icon background, which I personally like the look and feel of.
Does anyone here have an example of how I can implement a corresponding icon background with card mod? (It is the standard button card, not a custom version)
Thx in advance
What do you consider an icon background? color?
Sorry, that it was not clear - i mean the circle behind the icon as the tile card has it (so yes a different color)
i hope its clearer now
This will change the background of the icon or what is called the shape color.
type: tile
entity: light.bed_lights
card_mod:
style: |
ha-card {
--tile-color: red !important;
}
Add background:
to adjust the card color
type: tile
entity: light.bed_lights
card_mod:
style: |
ha-card {
--tile-color: red !important;
background: grey !important;
}
Great, thx a lot
But one more question, is it possible to geht this shape color on the button card?