This is a more global question (not related to the card):
Thanks. Yes. I know. But I want to have it refreshed every second and thought it could be done with a trick or setting in this card (or in general).
Probably may be achieved by using a template sensor with a small scan_interval (better to ask in Configuration)
Hi there, I’m trying to use this great work without luck yet. The problem is that I’m trying to show a weblink when a server is on (so I can turn it of correctly) but then, there are 2 “type” calls. Is there any solution.
- type: custom:template-entity-row
icon: mdi:web
name: Freenas Sotano
type: weblink
condition: "{{is_state('switch.freenas_sotano','on')}}"
url: http://192.168.1.20/
You may only use options described in the docs.
Is there a way to display the secondary row info on multiple lines?
I’ve tried a few things like yaml |+
or <br>
but can’t quite find the right syntax.
- type: custom:template-entity-row
entity: sun.sun
secondary: |
Elevation={{state_attr(config.entity,'elevation')}}
rise & shine
card_mod:
style:
div#wrapper: |
.info.pointer .secondary {
white-space: pre;
}
You may follow this FR:
I am trying to use the template-entity-row to display a weblink, where the URL is generated by some jinja template code. But I haven’t been able to work out how to make the URL that is displayed clickable. I have tried setting the tap_action to URL, but the actual jinga template that generates the URL doesnt seem to be evaluated.
Does anyone have any idea how I can include a template generated URL???
- type: entities
entities:
- entity: input_boolean.test_boolean
name: Yandex off, Google on
- type: custom:template-entity-row
icon: mdi:car
name: >-
Go to {{iif(is_state("input_boolean.test_boolean","on"),"google.com","yandex.ru")}}
state: ''
tap_action: |-
{{
{
"action": "url",
"url_path": "http://" + iif(is_state("input_boolean.test_boolean","on"),"google.com","yandex.ru")
}
}}
That has done the trick, thank you very much.
Previsouly I had:
- type: custom:template-entity-row
icon: mdi:web
name: Visit URL
state: ''
tap_action:
action: url
url_path: "http://" + iif(is_state("input_boolean.test_boolean","on"),"google.com","yandex.ru")
But having the template in just the url_path wasn’t being evaluated.
Is there a way to format the state just like they are in the regular entity rows, with capital first letter?
| capitalize
?
So easy! Thank you : )
If it is Away:
not_home → Not_home
For this local tracker it is better to do smth like:
if home → Home
else Away
(if you don’t bother about non-english localization)
Here is a possible PROPER handling (works with any language):
state: >-
{% if is_state(..................,'home') %}
_(component.device_tracker.state._.home)
{% else %}
_(component.device_tracker.state._.not_home)
{% endif %}
Vor {{ states[config.entity].last_changed|relative_time }}
to have the standard
BTW Is there a switch to get local text, so I can avoid
Vor {{ states[config.entity].last_changed |relative_time
|replace("hours","Stundem") |replace("hour","Stunde")
|replace("minutes","Minuten") |replace("minute","Minute")
|replace("seconds","Sekunden") |replace("second","Sekunde")
|replace("days","Tage") |replace("day","Tag") }}
here?
You cannot.
What you can use - there are localized resources (see in the docs).
Kind of this:
- type: custom:template-entity-row
entity: person.ildar
name: localized
state: _(component.device_tracker.state._.{{states(config.entity)}})
But some resources have “internal” keys - like strings for “hour, hours”, “minute, minutes” - to select a required variant. And this card does not seem to support these complex resources.
Check this issue.
Thanks. O.k. I stay with the approach above.
For the localized states, I hope still for jinja2 support via https://github.com/home-assistant/core/pull/65743 eventually, if someone will merge in whatever future.
That could be great
That “last-changed” string is a combination of substrings (which may be implemented manually by jinjia, if no other options are provided).
Probably, that method should allow to give a localized version of such a complex structure like “last-changed” as well.
I guess that “_(key)” is resolved only for “evaluated” templates - as it was mentioned in the docs:
Consider this example:
- type: custom:template-entity-row
entity: sun.sun
state: >-
{% set VALUE = states(config.entity) -%}
{%- set LOCALIZED_VALUE = '_(component.sun.state._.'+ VALUE + ')' -%}
{{LOCALIZED_VALUE}}
Now try this:
state: >-
{% set VALUE = states(config.entity) -%}
{%- set LOCALIZED_VALUE = '_(component.sun.state._.'+ VALUE + ')' -%}
{{LOCALIZED_VALUE | upper }}
Seems that the “_(key)” is mainly not supposed to be used INSIDE templates.
Check this:
state: >-
_(component.sun.state._.{{states(config.entity)}})
which returns a localized string.
But you cannot process this string by “templating” (using “upper” etc).
Registered an issue.
Not sure if t is a bug or a FR.
If anyone interested in multiline support for the card - please test this PR: