last_changed
and last_updated
are a bit odd onesā¦
{{ states[config.entity].last_changed }}
last_changed
and last_updated
are a bit odd onesā¦
{{ states[config.entity].last_changed }}
better!
bit of formatting makes it more readable:
secondary: "{{ as_timestamp(states[config.entity].last_changed)| timestamp_custom('%X - %D') }}"
Thomas, how can we reveal the more-info on these entities?
HI Thomas,
Since updating to 105.1/2 the above card using your auto-entities and template-entity-row is in a state of turmoilā¦ it shows like this now:
every few seconds flickers to its āsupposed to be stateā like posted above for a split second and then back to the full templates againā¦
Could it be either of these cards is having issues with HA 105?
this is the config for the cards:
- type: custom:auto-entities
card:
type: entities
title: Github repos
show_header_toggle: false
filter:
include:
- entity_id: sensor.github*
options:
type: custom:template-entity-row
state: >
{% if state_attr(config.entity,'latest_release_url') %}
{{ state_attr(config.entity,'latest_release_url').split('tag/')[1]}}
{% else %} Not set
{% endif %}
secondary: >
{{ state_attr(config.entity,'latest_commit_message')}}
which has been showing just fine up to now like posted here
This is great, thanks. It would be even better if it behaves like a normal card. So when I click it, it would be nice when it opens the entity. Is this possible too?
Something like tap_action in the glance card.
on my post above, this is solved with the latest update of your custom card, so thank you very much.
I do have another question (next to the open request for tap/hold-action ) which has revealed itself just now. As you can see the auto-entities config makes the sensors appear with the templated state and secondary info, but also with their given name, and default GitHub icon, belonging to the GitHub sensor.
I needed to add a single GitHub sensor to the card config, and without explicitly setting a name and icon this shows as:
adding the name and icon as follows:
- type: custom:auto-entities
card:
type: entities
# title: Github repos
show_header_toggle: false
header:
type: picture
image: /local/images/github_owler.png
entities:
- entity: automation.github_repo_update
secondary_info: last-triggered
- type: custom:template-entity-row
name: >
{{state_attr('sensor.home_assistant','name')}}
icon: >
{{state_attr('sensor.home_assistant','icon')}}
state: >
{% if state_attr('sensor.home_assistant','latest_release_url') %}
{{ state_attr('sensor.home_assistant','latest_release_url').split('tag/')[1]}}
{% else %} Not set
{% endif %}
secondary: >
{{ state_attr('sensor.home_assistant','latest_commit_message')}}
filter:
include:
- entity_id: sensor.github*
options:
# tap_action:
# action: more-info
type: custom:template-entity-row
state: >
{% if state_attr(config.entity,'latest_release_url') %}
{{ state_attr(config.entity,'latest_release_url').split('tag/')[1]}}
{% else %} Not set
{% endif %}
secondary: >
{{ state_attr(config.entity,'latest_commit_message')}}
sort:
method: name
makes it show like the other sensors:
how can this be? does the auto-entities card also automatically add the name and icon?
Iāve just started using this card and itās awesome, thanks @thomasloven!
I need some help from more experienced people with the following card.
It displays my motion sensors with their statuses (Clear
/Detected
instead of āoffā/on
), secondary info as a value of another (related to entity
) sensor and changing its iconās colour dependig on the entity
's state.
This is working the version (secondary
code shortened for clarity):
entities:
- type: custom:template-entity-row
entity: binary_sensor.pir_ground_floor_hall
secondary: >
{% set dt_obj = states.input_datetime.pir_ground_floor_hall %}
state: >
{{ 'Clear' if is_state('binary_sensor.pir_ground_floor_hall', 'off') else 'Detected' }}
active: "{{ is_state('binary_sensor.pir_ground_floor_hall', 'on') }}"
- type: custom:template-entity-row
entity: binary_sensor.pir_ground_floor_reception
secondary: >
{% set dt_obj = states.input_datetime.pir_ground_floor_reception %}
state: >
{{ 'Clear' if is_state('binary_sensor.pir_ground_floor_reception', 'off') else 'Detected' }}
active: "{{ is_state('binary_sensor.pir_ground_floor_reception', 'on') }}"
show_header_toggle: false
state_color: true
title: Motion detectors
type: entities
As you can see, there is little difference so I wanted to avoid repeating entities. After looking at this and this advice I tried to change my card to:
entities:
- type: custom:template-entity-row
entity: binary_sensor.pir_ground_floor_hall
secondary: >
{% set dt_obj = states.input_datetime.pir_ground_floor_hall %}
state: >
{{ 'Clear' if is_state(config.entity, 'off') else 'Detected' }}
active: "{{ is_state(config.entity, 'on') }}"
- type: custom:template-entity-row
entity: binary_sensor.pir_ground_floor_reception
secondary: >
{% set dt_obj = states.input_datetime.pir_ground_floor_reception %}
state: >
{{ 'Clear' if is_state(config.entity, 'off') else 'Detected' }}
active: "{{ is_state(config.entity, 'on') }}"
Entities do change icons when motion detected but states do not change (always Clear
) and colour is always blue.
Do I miss anything here or it wonāt work in my case? (I kind of understand how HA detects what entitiesā changes to listen to when rendering templates but people reported success with their config.entity
templatesā¦)
It also does not look like I can use any YAML anchors here, does it?
p.s as far as I understand from reading this topic, this card does not support tap_action
so if I need such functionality I need to look elsewhere?
Does the color change if you refresh the page while the sensor is on
?
yes, both state
and active
work if I refresh the page.
thatās why I doubted this {{ is_state(config.entity, 'on') }}
would ever work properly as itās a template and HA wonāt catch whatās inside config.entity
so there will be no re-evaluation and therefore no change (until something else causes re-evaluation)
By the way, when I move some logic from backend to LL (as I used to have some template sensors just to make them read-only like this one) does it shift processing from backend to a browser?
Iām asking because it seems like my sensors react a bit slower now and Iām trying to figure out whyā¦
Ok.
Iāll have a fix up later today.
Temporary workaround: add
entity_ids:
- binary_sensor.pir_...
Hi Thomas,
would you add the tap/hold action functionality also? Would be really very nice indeed.
Thatās very kind of you, thanks!
Just a thought:
I only need to re-define state
because (I think) standard LL entity row looks at my binary_sensor
ās device_class
and internally does that off
ā Clear
/on
ā Detected
substitution so I donāt see those off
/on
if I use standard entity row. Maybe your code could do the same?
That way there will be less template processing and generally room for error
On a similar note, I have active
ā¦ but itās much trickier considering the recent state of things with dropping colour changes in standard cards.
I just wanted to update my report based on some observation.
Your workaround let me see immediate changes in state but as my secondary info displays time elapsed from the last on
state in needs to be updated regularly.
So I ended up having this and it works better as being updated both upon state change and then every minute
entity_ids:
- binary_sensor.pir_ground_floor_lounge
- sensor.time
Donāt know if there is a better way of doing what I want thoughā¦
Just wanted to say a big thank you for the fix - I downloaded the latest version and it works for me without entity_ids
(even without sensor.time
- good stuff).
You donāt do releases of it, do you?
@thomasloven I have an issue similar to the previous one when using condition
as I want to hide my input_number
when an automation is disabled - my card is updated only if I refresh the page.
Hereās the simple config
type: entities
show_header_toggle: false
title: Ventilation
entities:
- entity: automation.ventilation_1st_floor_bathroom_extractor_fan_turn_on_by_humdity_threshold
- type: custom:template-entity-row
entity: input_number.ventilation_1st_floor_bathroom_shower_humidity_threshold
condition: >
{{ is_state('automation.ventilation_1st_floor_bathroom_extractor_fan_turn_on_by_humdity_threshold', 'on') }}
The workaround works, too
But there is another problem - that input_number
(mode: slider
, but mode: box
makes no difference) behaves like a sensor so I can see no box around it and cannot change its value.
Could you look into it please?
I recently learned that it is considered normal for template-entity-row to momentarily display its raw templates during a page-refresh (this may be true of other custom cards as well; I donāt know because I donāt use any others).
Template-Entity-Row momentarily displays its templates
My point of reference is Custom UI and its templates are never displayed in the UI. Can you explain to a novice like me how Custom UI and template-entity-row differ in their approach?
FWIW, Iām trying to replace Custom UI with purely Lovelace cards and techniques. My requirement is fairly simple: I want to change the icon (and its color) of an entities card based on the entityās state. Iām using style:
to set the iconās color and template-entity-row to set the icon. It produces the same appearance as Custom UI but has the additional undesirable feature of showing its templates during rendering.
I chose to display the original template as a fallback. That means that if the template fails to evaluate for any reason, you will be able to at least see it and possibly find out what went wrong.
That also means that on initial load, you will see the template until the backend can evaluate it and send the result back to the frontend.
Thank you for the explanation.
If I understood you correctly, you are saying the template is displayed by design. In other words, it is entirely feasible to not momentarily display the template but it was decided to display it.
I ask that you reconsider this design choice (or provide an option to enable/disable the display of templates). Hereās why:
yes, + 1 to that indeed.
We have to write correct templates, and have guards to prevent unknownāsā¦
if anything, an error could be logged stating the template is incorrect. If possible at all, drop the initial momentarily display, and show the evaluated result immediately.
hi Thomas,
please let me ask your assistance in rewriting some secondaryinfo-entity-rowās to your template-entity-row. I have this:
- type: custom:stack-in-card
title: Boiler switch monitor
cards:
- type: entities
show_header_toggle: false
entities:
- type: 'custom:secondaryinfo-entity-row'
entity: switch.sw_boiler_bijkeuken_sc
state_color: true
secondary_info: 'Actueel verbruik: [[ sensor.boiler_bijkeuken_actueel ]] watt'
- type: custom:template-entity-row
entity: switch.sw_boiler_bijkeuken_sc
active: >
{{is_state(config.entity,'on')}}
# state_color: true
secondary: >
Actueel verbruik: {{states('sensor.boiler_bijkeuken_actueel')}} watt
showing like:
I have 2 questions in particular:
would you consider adding support for state_color? As you can see I know we can use a template there, but as state_color is used in core HA, it might be a valuable addition, and make the config just that bit simpler (and not have to evaluate a jinja template could be beneficial to the system.)
can we have the toggle for a switch, instead of the value for state? dont think I found it in your docās. If no yet possible, would you consider adding that too please?
Thanks for considering!
+1 Only just started using thisā¦ replaced secondaryinfo-entity-row and card tools with it and that was the first thing I noticed as well.