Does it work now?
if you still wanted to use CTC and change the tittle colour and size try this
type: custom:config-template-card
variables:
STATE: states['sun.sun'].state
entities:
- sun.sun
card:
type: entities
card_mod:
style: |
ha-card .card-header {
font-size: 50px;
color: red;
}
title: ${"CyberPower " + STATE}
entities:
- sun.sun
change for your entities
the code does work and it was answered by someone in another topic. What I wanted was to reduce the size of the card title which apparently is not doable with CTC. No biggie. Was more of a wish list thing.
Nope - hence my post. Not sure how to fix it
many many thank youās. this is working as I had hoped. thanks to other who offered suggestions.
type: custom:config-template-card
variables:
STATE: states['sensor.ups_modelname_2'].state
entities:
- sun.sun
card:
type: entities
card_mod:
style: |
ha-card .card-header {
font-size: 15px;
}
title: ${"CyberPower " + STATE}
entities:
- entity: sensor.ups_serialno_2
name: Serial Number
- entity: sensor.ups_status_2
name: Status
- entity: sensor.ups_load_2
name: Load
- entity: sensor.ups_timeleft_2
name: Time Left
- entity: sensor.ups_nominv_2
name: Nominal Input Voltage
- entity: sensor.ups_nompower_2
name: Nominal Output Power
In case someone wants to see the final result.
See no errors which you described.
But (unrelated to your error):
- You have not provided āelseā value.
- Typo - āeifā.
- Use simply ā.valueā (no need to copy/paste & use blindly a code from examples, you can see that dom structure was changed since the time that ā.text-content:not(.info)ā was posted).
- I usually do not suggest using
color:
{% if ... %}
xxx
{% else %}
xxx
{% endif %} ;
this is more flexible (and note ā-ā):
{% if ... -%}
color: xxx;
{%- else -%}
color: xxx;
{%- endif %}
Thank you for that! Iāve made the changes but still getting that error. Can you see any problems?
Sorry not on my laptop at the moment
Oh, you meant Entity card, and I told you about Entities.
Yes, I see this WARNING in Entity card:
Since this is a Warning - you still can save the card.
I believed that you meant Entities - cause this card-mod is for Entities.
Surely it cannot be used for Entity card.
Trust me, card-mod code for a row inside Entities card never (at least from September 2020) worked for Entity cardā¦
If for āwork beforeā you mean āthere were no this warningā - have no ideaā¦
Imho these warnings appeared approximately at the time when "card_mod: keyword was added.
this can never have worked (anywhere), because you use the states()
method, where you need to use the is_state()
method.
(also the already mentioned typos for the eif
of course, but that is a mere typo, and not a fundamental templating error. use this:
{% if is_state(config.entity,'Good') %} automatic
{% elif is_state(config.entity,'Moderate') %} yellow
{% elif is_state(config.entity,'Poor') %} orange
{% elif is_state(config.entity,'Very Poor') %} red
{% elif is_state(config.entity,'Severe') %} purple
{% elif is_state(config.entity,'Hazardous') %} red
{% else %} black
{% endif %}
;
was it already mentioned that āautomaticā probably is an odd template outcome in this regard?
you can use a āmapperā in this case:
{% set state = states(config.entity) %}
{% set quality = {'Good':'automatic',
'Moderate':'yellow',
'Poor':'orange',
'Very Poor':'red',
'Severe':'purple',
'Hazardous':'red' } %}
{{quality.get(state,'black')}}
btw using āredā twice.
This is Entities card, not Entity card
btw, did you consider using a template-entity-row title template?
the config-template-card is a terrible memory hog, and, if all you want is to reflect the state of that sensor entity, just use it inside the entities card itself?
Maybe not even as a template-entity-rowā¦ a plain entity would provide all the info at a glance, without hogging your view.
config-template-card is best use sparsely and only for those cases where you actually need to change the card config itself, not so much for displaying a string somewhere. Of course you can, but it is very much a waste of resources.
if you must use it in the header, add it to an embedded markdown card in the stack. and then position that nicely using card-mod (bringing it back on topic here )
I believe marius is on about something like this.
type: vertical-stack
cards:
- type: markdown
card_mod:
style: |
ha-card {
font-size: 20px;
margin-bottom: -10px;
border-bottom: none;
border-radius: 10px 10px 0px 0px;
content: CyberPower {{ states('sensor.kettle_wifi_status')}}
- type: entities
card_mod:
style: |
ha-card {
border-top: none;
border-radius: 0px 0px 10px 10px;
entities:
- entity: sensor.ups_serialno_2
name: Serial Number
- entity: sensor.ups_status_2
name: Status
- entity: sensor.ups_load_2
name: Load
- entity: sensor.ups_timeleft_2
name: Time Left
- entity: sensor.ups_nominv_2
name: Nominal Input Voltage
- entity: sensor.ups_nompower_2
name: Nominal Output Power
you could use stack-in-card which makes it seamless between the two. obviously just change out my senaor
exactly that yes, thanks
also, no need for stack-in-card, just use card-mod to remove the gaps between the cards
other than that, this is what I do in most of the cards where I need the Title to reflect some actual state.
that, or use a custom:button-card, with specific āheaderā stylings.
or
thank you. I will play around with the new code suggestion. I think right now I am just trying to maximize the space I have on the tabs I have on my dashboard. Clean stuff up a bit. Still in the very early stages as I stumble my way through stuff.
Can confirm it does work @Frosty @Mariusthvdb - I am deferring to you guys about CTC being a memory hog. As is I wonder if my experience is not optimized due to me using Firefox. Wonāt use Edge or Chrome - wonāt go there why I wonāt. I see no difference which is good. I might still play around with the border-radius so this can be more compact. Like to get the values pushed more over to the left. Wish list. I am happy with this.
thank you so much! Iāll try it out
sure, welcome.
let us know your findings