#entity not available

1 messages · Page 1 of 1 (latest)

fleet gale
void portal
#

that means the entity does not exist... are you trying to create a template that includes all states except those which don't exist?

fleet gale
#

yes, basically.

#

I already have the template to filter what I need, all entities of a specific device. I just need to ignore those which dont exeist.

void portal
#

you shouldn't get them already

#

they don't exist

#

there's nothing to be included in the first place

fleet gale
#

I am using the template filter of auto-entities card. It is listing to me these entities that don't exist. Is the only choice for me to manually delete them?

hard cloud
#

| selectattr('state','in',['unavailable','unknown']) on your expanded group or list of state objects.

#

expand('sensor.1', 'sensor.2') | selectattr(...

fleet gale
#

Thanks, I will save this info. This time I was not able to test it because I restarted HA and that got rid of all those non-existing entities.

fleet gale
#
{% set device = test_device %} 
{% set id = device_id(device) %}
{{ device_entities(id) | selectattr('state','in',['unavailable','unknown'] | list}}

Is this the way I am supposed to use it? without the selectattr part it does return a proper list with it, it is empty. If it was at least a list of unavailable I would use that list to exclude.

#

btw I am trying to exclude non existing entities like in the picture, there are more now besides the ones that disapeared.

#

in devtools states it does not even list those entities so I guess they don't have a state.

hard cloud
#

if you want to exclude them, use rejectattr

#

rejectattr, selectattr, reject, select

#

4 methods of filtering items

#

if you 'select', that means youre going to get those items which is opposite of what you want

fleet gale
#
{% set id = device_id(device) %}
{% set entities = device_entities(id) | rejectattr('state','in',['unavailable','unknown']) | list %}

{% for entity in entities %}
{%- if states(entity) != 'unknown' %}
{{ entity }} = {{ states(entity) }}
{%- endif -%}
{% endfor %}

Without the for block it is still listing unknown entities. With it the if statement is successfully filtering out unavailable entities.
I suspect that since those entities don't show up in developer tools | states they don't exist and therefore don't have a state unknown so they don't get rejected. When they need to return a state they return unknown just like asking for the state of any other non-existing entity i.e states('sensor.made_up_entity') will return unknown

hard cloud