josephny
(Joseph)
December 1, 2023, 4:16am
1
Is it me???
The following just won’t work.
Card:
type: entity
entity: sensor.76_temperature
name: !secret name
secrets.yaml:
name: "TESTING"
What am I doing wrong?
I started by trying to use card_mod secret but that didn’t work, so I simplified with the above and still can’t get it to work.
card_mod: !secret color
With secrets.yaml:
color:
style: |
:host {
--paper-item-icon-color:
{% set state = states(config.entity)|int(-5) %}
{% if state == 'unknown'%} gray
{% elif state < -20 %} black
{% elif state < -15 %} navy
{% elif state < -10 %} darkblue
{% elif state < -5 %} mediumblue
{% elif state < 0 %} blue
{% elif state < 5 %} dodgerblue
{% elif state < 10 %} lightblue
{% elif state < 15 %} turquoise
{% elif state < 20 %} green
{% elif state < 25 %} darkgreen
{% elif state < 30 %} orange
{% elif state < 35 %} crimson
{% else %} firebrick
{% endif %};
}
jchh
((not John))
December 1, 2023, 11:56am
2
The first example and the secrets.yaml
look fine to me.
Is secrets.yaml
located in /config
(alongside the likes of home-assistant_v2.db
)?
rcblackwell
(Robert Blackwell)
December 1, 2023, 12:01pm
3
Have you tried enclosing name in a single quote?
type: entity
entity: sensor.76_temperature
name: !secret 'name'
josephny
(Joseph)
December 1, 2023, 12:04pm
5
Just tried both single and double quotes. Still no luck:
jchh
((not John))
December 1, 2023, 12:04pm
6
I’m not sure you can do any of the text_color
or temp_color2
type things in the secrets.yaml
file. It’s not a subroutine thing.
Only name: TESTING
will work and the other entries might even stopping that from working.
Can you remove text_color
or temp_color2
and see if name:
works then?
edit: You can try this for card_mod:
though
card_mod: !include color
color.yaml
style: |
:host {
--paper-item-icon-color:
{% set state = states(config.entity)|int(-5) %}
{% if state == 'unknown'%} gray
{% elif state < -20 %} black
{% elif state < -15 %} navy
{% elif state < -10 %} darkblue
{% elif state < -5 %} mediumblue
{% elif state < 0 %} blue
{% elif state < 5 %} dodgerblue
{% elif state < 10 %} lightblue
{% elif state < 15 %} turquoise
{% elif state < 20 %} green
{% elif state < 25 %} darkgreen
{% elif state < 30 %} orange
{% elif state < 35 %} crimson
{% else %} firebrick
{% endif %};
}
rcblackwell
(Robert Blackwell)
December 1, 2023, 1:54pm
7
You may be correct on this. Information from “Storing Secrets” indicates;
The configuration.yaml
file is a plain-text file, thus it is readable by anyone who has access to the file. The file contains passwords and API tokens which need to be redacted if you want to share your configuration. By using !secret
you can remove any private information from your configuration files. This separation can also help you to keep easier track of your passwords and API keys, as they are all stored at one place and no longer spread across the configuration.yaml
file or even multiple YAML files if you split up your configuration .
@josephny - I think the key here is storage of passwords and API tokens. There’s no mention of storing anything else. I think, as @jchh mentions, !include may be the correct approach.
1 Like
tom_l
December 1, 2023, 9:11pm
8
!secrets and !include only work in yaml mode for the frontend.
1 Like
josephny
(Joseph)
December 1, 2023, 11:51pm
9
Tom: Could you please point me to how to be in “yaml mode?”
I thought by the following was yaml mode:
tom_l
December 1, 2023, 11:54pm
10
If you are editing via the UI you are using storage mode. YAML mode is done entirely from a text editor.
See: https://www.home-assistant.io/dashboards/dashboards/#using-yaml-for-the-default-dashboard
josephny
(Joseph)
December 2, 2023, 12:12am
11
Thank you.
I’m a little leary of switching to yaml mode, as it looks like it quite substantially changes how dashboards are created and modified.
All of this came about because I wanted to repeat card_mod code on an entities card with 20+ temperature entities. Ugh.
tom_l
December 2, 2023, 12:37am
12
The other option is to use card-mod themes.
Then you can apply complex styling just by doing:
card_mod:
class: top-level-card
Themes.yaml:
#################################################################
## Day
#################################################################
day:
### Main Interface Colors ###
primary-color: etc...
## Card Mod Day
###############
card-mod-theme: day
card-mod-card: |
h1.card-header {
font-size: 20px;
font-weight: 300;
letter-spacing: 0px;
}
ha-card.top-level-card {
border: solid 1px var(--primary-text-color);
background: linear-gradient(rgba(147, 171, 202, 1), rgba(255, 255, 255, 0.6) 56px, rgba(255, 255, 255, 0.6) 100%);
}
ha-card.top-level-card h1.card-header {
padding-top: 0px !important;
padding-bottom: 28px !important;
See here for more: 🔹 Card-mod - Super-charge your themes!
1 Like