thomasloven
(Thomas Lovén)
January 8, 2024, 11:53am
5707
Hi!
Just wanted to drop in and say sorry about the “sudden” change from
style:
to
card_mod:
style:
in card-mod 3.4.0.
The new method has been recommended for over two years, so when I redid the background workings I… forgot about the old syntax.
I could have been more clear in the communication (again I forgot about it, so I didn’t even realize there was anything to communicate at first).
It was a pain to maintain and support both configuration methods though, so I will not go back on this.
Hope you all enjoy card-mod!
11 Likes
Olivier1974
(Olivier Toussaint)
January 8, 2024, 1:28pm
5709
Lol, don’t be sorry, it is not like nobody knew that it might disappear one day.
Such a great tool btw.
1 Like
oh. my. god… sorry… I really did miss that… that’ll put me on @thomasloven 's nono-list I guess. Sorry Thomas!
indeed, an amazing tool. It went from boring to, make your dashboard as beautiful as possible and then throwing away the design and start over every 2 months. thanks a million @thomasloven and @Olivier1974
DrSpaldo
(Doctor Spalding)
January 8, 2024, 1:54pm
5712
I have started getting new issues, but I have been using the newer format?
This “newer format” was recommended 2 years ago.
DrSpaldo
(Doctor Spalding)
January 8, 2024, 2:03pm
5714
I am not sure if that reply was for me, but, I have been using the newer format since 2021… But the problem I was trying to explain only started since 3.4.x
arganto
January 8, 2024, 2:23pm
5715
I have tested yours and see errors in card-mod as well.
card-mod.js:1 Card-mod TypeError: Cannot read properties of undefined (reading 'apply')
at HTMLElement.value (card-mod.js:1:59842)
at HTMLElement.i (card-mod.js:1:52936)
at t.setConfig (layout-card.js?hacstag=156434866244:215:1564)
at HTMLElement.value (card-mod.js?hacstag=190927524341:1:59842)
at HTMLElement.i [as setConfig] (card-mod.js?hacstag=190927524341:1:52936)
at F.value (hui-element-editor.ts:377:31)
And if I try to simplify, e.g. to
card_mod:
style:
.entities:
$: |
state-badge {
margin-top: 20px;
margin-bottom: -5px;
}
.name {
margin-top: 0px !important;
margin-bottom: -10px !important;
}
div:not(.name) {
margin-bottom: 0px !important;
}
The ingestions is somehow weared.
Don’t know if it is card-mod update related, but at least I can confirm, that something is strange here.
Perhaps better to open an issue in the repository?
Tested with
type: vertical-stack
cards:
- type: glance
card_mod: &ref_card_mod
style:
.entities .entity $: |
state-badge {
background-color: red;
}
.name {
color: cyan;
}
div:not(.name) {
color: orange;
}
entities:
- entity: sun.sun
name: Front 1
show_state: false
- entity: sun.sun
name: Front 2
show_state: false
- entity: sun.sun
name: Front 3
show_state: false
- type: glance
show_name: false
card_mod: *ref_card_mod
entities:
- entity: sun.sun
show_name: false
name: Motion
show_last_changed: true
- entity: sun.sun
show_name: false
name: Motion
show_last_changed: true
- entity: sun.sun
show_name: false
name: Motion
show_last_changed: true
- type: glance
card_mod: *ref_card_mod
entities:
- entity: sun.sun
name: Garage
show_state: false
- entity: sun.sun
name: Side
show_state: false
- entity: sun.sun
name: Back 1
show_state: false
- entity: sun.sun
name: Back 2
show_state: false
- type: glance
show_name: false
card_mod: *ref_card_mod
entities:
- entity: sun.sun
show_name: false
name: Motion
show_last_changed: true
- entity: sun.sun
show_name: false
name: Motion
show_last_changed: true
- entity: sun.sun
show_name: false
name: Motion
show_last_changed: true
- entity: sun.sun
show_name: false
name: Motion
show_last_changed: true
Styles seems to be stable:
But when the card is opened in UI editor, I see these errors in Code Inspector:
rd-mod r: At path: entities.0 -- Expected the value to satisfy a union of `object | string`, but received: [object Object]
at d (http://192.168.220.32:8123/frontend_latest/38768.-gCP239u5SQ.js:1:2807)
at f (http://192.168.220.32:8123/frontend_latest/38768.-gCP239u5SQ.js:1:2615)
at F.value (http://192.168.220.32:8123/frontend_latest/20207.KXnjAt08q54.js:2:13710)
at F.value (http://192.168.220.32:8123/hacsfiles/lovelace-card-mod/card-mod.js:1:59842)
at F.i (http://192.168.220.32:8123/hacsfiles/lovelace-card-mod/card-mod.js:1:52936)
at t.setConfig (http://192.168.220.32:8123/hacsfiles/lovelace-layout-card/layout-card.js?hacstag=156434866244:215:1564)
at F.i [as setConfig] (http://192.168.220.32:8123/hacsfiles/lovelace-card-mod/card-mod.js?hacstag=190927524341:1:53062)
at F.value (http://192.168.220.32:8123/frontend_latest/21948.wVYWKAjUy9c.js:1:15379)
and do not see these errors if not opened in UI editor.
An even in UI editor this MAY NOT happen.
Also:
.name {
...
}
div:not(.name) {
...
}
The “.name” style will be applied only if name is shown (which is not is some cards).
The "div(…) style will be applied only if state/last-chaged is shown (which is not is some cards).
Unrelated to card-mod:
defining “name” has no sense since name is hidden:
- entity: binary_sensor.frontroad_person_occupancy
show_name: false
name: Motion
I would say I can reproduce the glance card issue w/o card-mod:
A code:
type: glance
entities:
- entity: sun.sun
name: Front 1
show_state: false
- entity: sun.sun
name: Front 2
show_state: false
- entity: sun.sun
name: Front 3
show_state: false
No errors:
UI editor open:
opened 03:29PM - 08 Jan 24 UTC
My Home Assistant version: 2024.1.1
My lovelace configuration method (GUI or … yaml): storage
What I am doing:
Creating a Glance card w/o card-mod in UI Editor.
What I expected to happen:
No errors in Code Inspector & UI Editor.
What happened instead:
1. Errors are shown in UI Editor (MAY BE NOT related to card-mod):
Visual editor is not supported for this configuration:
Key 'entities.0.show_state' is not expected or not supported by the visual editor.
The provided value for 'entities.0' is not supported by the visual editor. We support (string) but received ({"entity":"sun.sun","name":"Front 1","show_state":false}).
Key 'entities.1.show_state' is not expected or not supported by the visual editor.
The provided value for 'entities.1' is not supported by the visual editor. We support (string) but received ({"entity":"sun.sun","name":"Front 2","show_state":false}).
Key 'entities.2.show_state' is not expected or not supported by the visual editor.
The provided value for 'entities.2' is not supported by the visual editor. We support (string) but received ({"entity":"sun.sun","name":"Front 3","show_state":false}).
You can still edit your config in YAML.
2. Errors are shown in Code Inspector:
Card-mod r: At path: entities.0 -- Expected the value to satisfy a union of `object | string`, but received: [object Object]
at d (http://192.168.220.32:8123/frontend_latest/38768.-gCP239u5SQ.js:1:2807)
at f (http://192.168.220.32:8123/frontend_latest/38768.-gCP239u5SQ.js:1:2615)
at F.value (http://192.168.220.32:8123/frontend_latest/20207.KXnjAt08q54.js:2:13710)
at F.value (http://192.168.220.32:8123/hacsfiles/lovelace-card-mod/card-mod.js:1:59842)
at F.i (http://192.168.220.32:8123/hacsfiles/lovelace-card-mod/card-mod.js:1:52936)
at t.setConfig (http://192.168.220.32:8123/hacsfiles/lovelace-layout-card/layout-card.js?hacstag=156434866244:215:1564)
at F.i [as setConfig] (http://192.168.220.32:8123/hacsfiles/lovelace-card-mod/card-mod.js?hacstag=190927524341:1:53062)
at F.value (http://192.168.220.32:8123/frontend_latest/21948.wVYWKAjUy9c.js:1:15379)
at F.value (http://192.168.220.32:8123/frontend_latest/21948.wVYWKAjUy9c.js:1:11120)
at F.value (http://192.168.220.32:8123/frontend_latest/21948.wVYWKAjUy9c.js:1:10811)
With no UI Editor open after browser's refresh (F5) - no errors:
![image](https://github.com/thomasloven/lovelace-card-mod/assets/71872483/c79f3ad5-e1c0-4d3d-8c6a-e346795a07ac)
With UI Editor open:
![image](https://github.com/thomasloven/lovelace-card-mod/assets/71872483/7b330083-e74e-42cd-b94b-7b2eb9446fac)
**Minimal** steps to reproduce:
```
type: glance
entities:
- entity: sun.sun
name: Front 1
show_state: false
- entity: sun.sun
name: Front 2
show_state: false
- entity: sun.sun
name: Front 3
show_state: false
```
Error messages from the browser console:
---
**By putting an X in the boxes ([]) below, I indicate that I:**
- [x] Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).
- [x] Have made sure I am using the latest version of the plugin.
- [x] Have followed the troubleshooting steps of the "Common Problems" section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.
- [x] Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.
Errors in UI editor itself are not related to card-mod & may be reproduced on a system w/o card-mod:
opened 03:59PM - 08 Jan 24 UTC
### Checklist
- [X] I have updated to the latest available Home Assistant versi… on.
- [X] I have cleared the cache of my browser.
- [X] I have tried a different browser to see if it is related to my browser.
- [X] I have tried reproducing the issue in [safe mode](https://www.home-assistant.io/blog/2023/11/01/release-202311/#restarting-into-safe-mode) to rule out problems with unsupported custom resources.
### Describe the issue you are experiencing
1. Add a new Glance card.
2. Switch to yaml.
3. Type this code:
```
type: glance
entities:
- entity: sun.sun
show_state: false
```
4. See this error:
```
Visual editor is not supported for this configuration:
Key 'entities.0.show_state' is not expected or not supported by the visual editor.
The provided value for 'entities.0' is not supported by the visual editor. We support (string) but received ({"entity":"sun.sun","show_state":false}).
You can still edit your config in YAML.
```
![image](https://github.com/home-assistant/frontend/assets/71872483/6dd36117-e9db-4b73-8d7d-d243c0ce57fa)
### Describe the behavior you expected
No errors
### Steps to reproduce the issue
as above
### What version of Home Assistant Core has the issue?
2024.1
### What was the last working version of Home Assistant Core?
_No response_
### In which browser are you experiencing the issue with?
Chrome 120.0.6099.200
### Which operating system are you using to run this browser?
Win10x64
### State of relevant entities
_No response_
### Problem-relevant frontend configuration
_No response_
### Javascript errors shown in your browser console/inspector
_No response_
### Additional information
_No response_
Okay, I’ll try again. Maybe I wasn’t that clear in the first place.
I am not that deep into css-styles. I have trouble to find out which elements to change to get the results I need.
The most important thing for me is to move the card around with the values of “left”, “right” and “top” or something that has the same affect.
Previously the values did work in the “:host” section but now I can’t figure out where to put them now.
This is an example code which needs some love:
- type: custom:hui-element
card_type: custom:mini-graph-card
points_per_hour: 4
line_width: 2
font_size: 80
name: CPU Auslastung 15min
align_header: center
show:
extrema: false
state: false
points: false
labels: true
fill: true
legend: false
icon: false
name: true
hours_to_show: 48
hour24: true
entities:
- entity: sensor.rammelsau_cpu_load_average_15_min
aggregate_func: min
color_thresholds:
- value: 80
color: red
- value: 40
color: green
- value: 41
color: yellow
- value: 42
color: yellow
card_mod:
style: |
:host {
left: 90.8%;
top: 58%;
width: 60.4%;
--ha-card-border-width: 0px 3px 3px 0px;
--ha-card-border-color: #212121;
}
ha-card {
border-radius: 1vw;
position: relative;
padding: 0 !important;
}
.graph__labels {
font-size: 15px !important;
padding: 0px 0px 0px 5px !important;
}
.header {
padding: 5px 0px 0px 0px !important;
}
No, that was my reply to “newer format” )))
Yeah, picture-elements is the background and the cards are the elements.
I would use fixed values. So a static position is what I need.
No hui-element needed for a custom card on picture-elements:
type: picture-elements
elements:
- type: custom:mini-graph-card
entities:
- sensor.processor_use
style:
top: 32%
left: 40%
image: /local/images/test/lightgreen.jpg
catboxer
(catboxer)
January 9, 2024, 2:32pm
5725
With the change over to the new style format, I’m having trouble getting my Badges to change color. I’m sure it’s a spacing/formatting issue with CSS. Can anyone tell me the correct indentations I should be using?
Old:
card_mod: null
style: |
ha-card {
--ha-card-background: teal;
color: var(--primary-color);
New attempt, but doesn’t work:
card_mod:
style: |
ha-card {
--ha-card-background: teal;
color: var(--primary-color);
}
Been hacking at this for an hour, but not great at CSS. I want my blue badges back
catboxer:
my Badges
what is it?
catboxer:
Old:
card_mod: null
style: |
It never been this way.
In ver. 3.3 you were suggested to add “card_mod” keyword, and you added in a wrong way w/o indentation.