Hi - I am using card-mod extensively to modify look & feel of a bunch of stock symbol grids - upwards of about 50 individual stocks / indexes, etc. The card-mod is identical on all of them. Wondering if there is any way to “include” a card-mod style and use a variable rather than having to write card-mod for every single graph? I’m envisioning a file that could be called to include the script possibly? Thoughts?
Sample image: (background color and icon indicate today up or down, border-top green indicates trading above 50 day average, border-bottom red indicates trading below 50 day average)
Sample card-mod script for 3M: (as you can see I already set the variable name and then use it throughout card-mod so I don’t have to retype/recopy when I update the script…):
entities:
- sensor.yahoofinance_mmm
graph: line
hour24: false
hours_to_show: 12
points_per_hour: 30
name: 3M Company
decimals: 2
show:
extrema: false
icon: true
name: true
legend: false
type: custom:mini-graph-card
card_mod:
style: |
{% set symb = 'sensor.yahoofinance_mmm' %}
ha-card {
box-shadow:
{% if states(symb)|float(0)
> state_attr(symb,'fiftyDayAverage')|float(0) %}
inset 0px 5px 0px 0px rgb(0,215,0,1)
{% else %}
inset 0px -5px 0px 0px rgb(255,0,0,1)
{% endif %};
background-color:
{% if state_attr(symb,'regularMarketChange')|float(0) > 0 %}
rgb(0,255,0,0.05)
{% else %} rgb(255,0,0,0.2)
{% endif %};
font-size: 80% !important;
}
.states.flex {
flex-direction: column;
}
.states.flex::after {
color: white;
padding-top: 16px;
content: "50 Day: {{ '{:.2f}'.format(state_attr(symb,'fiftyDayAverage')|float(0)|round(2)) }}";
}
:host {
--paper-item-icon-color:
{% if is_state_attr(symb,'trending','up') %}
rgba(170, 255, 0,1);
{% elif is_state_attr(symb,'trending','down') %}
rgba(255,0,0,1);
{% else %}
white;
{% endif %}
}