I have WHOIS integration with a couple of domains I own.
I’d like to use auto-entities card to display list of domains and order them by expiration date.
I was able to do this using:
type: custom:auto-entities
card:
show_header_toggle: false
title: Domeny
type: entities
unique: true
show_empty: true
filter:
include:
- integration: whois
entity_id: sensor.*_days_until_expiration
options:
secondary_info: last-changed
sort:
method: state
but this gives me those ugly names (sensor names):
I did a second version using a template:
type: custom:auto-entities
card:
show_header_toggle: false
title: Domeny
type: entities
unique: true
show_empty: true
filter:
template: >-
{% set DOMAINS = states.sensor | selectattr('entity_id', 'in',
area_entities('Biuro')) -%}
{%- for domain in DOMAINS if
(domain.entity_id.endswith('_days_until_expiration')) -%}
{%- set NAME = domain.entity_id -%}
{%- set DOMAIN_NAME = NAME.replace('_days_until_expiration','').replace('sensor.','').replace('_','.') -%}
{%- set EXPIRES = domain.attributes.expires -%}
{{
{ 'entity': NAME,
'name': DOMAIN_NAME,
'secondary_info': 'EXPIRES'
} }},
{%- endfor %}
sort:
method: state
and this looks better (I see proper domain names):
But I’m trying to add the actual expiration date in the secondary info.
How can I do that?
In the first version I used the secondary_info
option, but it shows me the last update value, not the attribute that I want.
My questions are:
- How can I change the displayed name of the entity in the first version? (I prefer it because it looks simpler and I don’t need jinja template for it)
- How to use attribute from my entity as a secondary info
- How to filter by integration in the template in version two.
{% set DOMAINS = states.sensor | selectattr('entity_id', 'in', area_entities('Biuro')) -%}
here I’d like to add a filter to include only sensors from whois integration