I would like to alter the look of the custom:weather-card fron Bram Kragten. I am an absolute beginner on this, and just start playing with the DOM Inspector after reading about this. I found the items i would like to change.
This is the card i want to change and below the card I changed via DOM inspector:
The changes are obvious in the header part of the card. This is the default code of the card:
type: custom:weather-card
entity: weather.home
number_of_forecasts: '5'
name: Het weer
I made an overview of the items i would like to change:
You are doing it wrong!
card-mod.js?hacstag=190927524315:5 mod-card should NEVER be used with a card that already has a ha-card element, such as weather-card
OK, Does anyone knows how to change this Card? Perhaps @bramkragten the maker of this card?
Hi @Mariusthvdb Marius,
You are right! I browsed the file weather-card.js and found the items to change. Success!
It was more the fear of the unknown; I have never done this before. AND I was hoping I could change this with the mod-card from Thomas Loven.
But it was actually quite simple. Looking back I feel myself a bit foolishâŚ
Thanks for putting me in the direction.
Most probably these are very old examplesâŚ
In some cases I also used kind of âha-card some_elementâ.
In most cases â:hostâ & âha-cardâ will not harm - but they should be omitted, actually.
Ah o.k. Thought there is some magic đ§ââď¸ behind. ha-card was/is fine. But :host is no html element/dom-path-selector, so most probably it was never necessary, but worked with it as well by chance.
- entity: person.marijn
card_mod:
style: |
:host {
--ha-label-badge-label-color: black;
{% set zones = states.zone|map(attribute='name')|list %}
{% set id = config.entity.split('.')[1] %}
{% set activity = states('sensor.' ~ id ~ '_activity') %}
{% set cc = state_attr('sensor.' ~ id ~ '_geocoded_location','ISO Country Code')|lower %}
{% if cc and cc != 'nl' %}
--label-badge-red: white;
{% elif is_state(config.entity,'home') %}
--label-badge-red: green;
--ha-label-badge-label-color: gold;
{% elif 'bij' in states(config.entity) %}
--label-badge-red: gold;
{% elif activity in ['Automotive','Cycling','Walking'] or
states(config.entity) in zones %}
--label-badge-red: mediumslateblue
{% else %}
--label-badge-red: #636B75;
{% endif %}
}
You need :host there. And you are assigning things for :host. That is fne. I only wanted to address, that afaik we donât need the :host in the path example above. and/or wanted to know if there is some unknown hidden magic behind it otherwise.
No no no, only when used for some element inside some cards and only when used alone (w/o additional selectors). In other cases it may be omitted and actually should not be used.
Great examples for using restriction-card in row mode. I need to use it with buttons, where the look gets very strange. I guess this is caused by restriction-card in combination with button-card.
The main issue is: it does not maintain / use the height like the other ânormalâ button cards do when being used in a grid.
For testing purposes: the used height: 300px; is not respected at all.
And even if it would: I canât absolutely define the height in px, it must be something fluent/automatical like âmaximumâ or something like that.
Problem screenshot:
left one is restriction-card with button-card, right one is normal button card (mind the gap below the left one):
Please note the view is configured to use the grid (layout card), in case that is important (tested also with default/standard, which also gives different look):
Question (@Ildar_Gabdullin):Is there any possibility to get a button-card inside a restriction-card to use the maximum/same height as other elements (normal button cards) in that grid
This really is a mission-critical thing as this should be used all over my lovelace dashboards. Hope thereâs a solution to have the restriction-card features while at the same time keeping a nice and ânaturalâ/original design.