Hey. I need to integrate a elseif statement into my lovelace-card-mod style. I want to react to the window sensors. And they know: open, tilted and closed. But I only manage to react to two conditions:
Thank you! But something doesnât seem to be correct yet. Is that maybe because the HACS plugin doesnât know these parameters? The button remains without color and is normally displayed as a button.
Sorry to revive an old thread here - but I felt the topic is quite similar to the problem I have.
I want to draw a red border around the temperature card if the heating is on, draw a white border when the heating is off and the door is open. When the heating is off and door is closed, no border.
(Iâve an automation that turns the heating off when the door is open)
The white border appears as intended, however the red border when the heating is on isnât⌠Here is the card config as I have it now:
type: custom:mini-graph-card
name: Living Room
entities:
- entity: sensor.average_mi_li_room_temperature
line_color: blue
card_mod:
style: |
ha-card {
border:
{%- set sensor = states('input_boolean.living_room_temp_vs_heating_set_point') %}
{%- set sensor2 = states('binary_sensor.living_room_door_sensor_contact') %}
{%- if sensor and sensor2 == 'off' %}
{%- elif sensor == 'on' and sensor2 == 'off' %}solid 3px red
{%- elif sensor == 'off' and sensor2 == 'on' %}solid 3px white
{%- else %}
{%- endif %}
Edit: found the prroblem, had to change the first if need to change to {%- if sensor == off and sensor2 == âoffâ %}
Iâm trying to do something similar, but with a gauge card and changing the border color based on several numerical values. The difference is I would like to use less than or greater than ( < or > ) but I canât find a way to make it work with CSS. Is using less than or greater than not possible with card mod?
Iâm not a Jinja ninja, so really donât know Searching through the forums I saw that the more knowledgeable people here said that you need to convert the state of an entity (which provides numerical values) into a float, in order to perform mathematical comparisons.
About card_mod, I really donât know css, so Iâm just following what I see on the forums, and find what works by trial and error.
No worries, trial and error is how Iâve learned pretty much everything about Home Assistant. There really needs to be a Home Assistant University or something.
This is really helped me a lot, I was locking for the background colour depends on zone and this template work as a charm. Just changed the sensor the colour codes
Hey everyone! I am trying to use a combination of mod-card, mushroom cards, and the custom variables component to highlight the outside of an icon when the variable == âOverviewâ.
I was able to get the color condition working within the mushroom card to turn the icon blue when the variable == âOverviewâ but am having trouble getting it working within the card-mod section of the code.
Yes, you can use âclassâ option within âcard_modâ.
But it is not possible to use âclassâ as a style like that person does.
Means - this is normal and supported: