Closed alanmilinovic closed 1 year ago
In HA (not talking about config-template-card
) secrets may be used only for defining a key:
value_template: !secret my_secret
but not inside templates:
value_template: >-
{{ "some_value" + !secret my_secret}}
And the same (almost) is about config-template-card
.
Consider an example:
- type: custom:config-template-card
variables:
ENTITY: states['input_boolean.test_boolean']
TEXT: '''some text'''
entities:
- ${ENTITY.entity_id}
card:
type: entity
entity: sun.sun
name: ${"State is " + ENTITY.state + " (" + TEXT + ")"}
Assume you need to keep "'some text" as a secret:
my_secret: "some_text"
and then trying to use it here:
- type: custom:config-template-card
variables:
ENTITY: states['input_boolean.test_boolean']
entities:
- ${ENTITY.entity_id}
card:
type: entity
entity: sun.sun
name: ${"State is " + ENTITY.state + " (" + !secret my_secret + ")"}
which will not work.
Then - following the logic described above - you decide to use the secret to define a variable:
- type: custom:config-template-card
variables:
ENTITY: states['input_boolean.test_boolean']
TEXT: !secret my_secret
entities:
- ${ENTITY.entity_id}
card:
type: entity
entity: sun.sun
name: ${"State is " + ENTITY.state + " (" + TEXT + ")"}
and again it will not work. This is all about defining string variables in the card - you have to specify a string variable as:
TEXT: '''some text'''
or
TEXT: >-
'some text'
and NOT as it usually works in other places in HA:
TEXT: some text
or
TEXT: "some text"
I call it "inconsistency".
Unfortunately, the card seems to be abandoned.
Thank you for your reply, but I lost you somewhere in the middle. :)
I stayed with using alternative solution in the end with input.select and used secret there.
input_select:
password:
name: Password
options:
- !secret password
icon: mdi:account-key
Is there any alternative that replaces this card as it is abandoned?
The card still may be used for some cases. I am still using it. Yes, there are issues which are not even reviewed by the card's author during a very long time - that is why I am saying that the card is abandoned.
As for alternatives - it depends on what you need. Some results may be achieved by other custom cards like template-entity-row
, some by using template sensors, some - by using templates with card-mod.
In you particular case I suggest you to use a template sensor for the url
option.
but I lost you somewhere in the middle. :)
no problem)
Isn't it too much to use template sensor for a static value? I am trying to avoid filling database with history records.
DB is filled mainly by CHANGING values.
Hi, is it possible to use secret. I tried following in my iframe card but it is not working:
This is working alternative, but not what I wanted: