thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.26k stars 115 forks source link

Is it possible to filter by unset values? #370

Open igorsantos07 opened 1 year ago

igorsantos07 commented 1 year ago

I didn't find in the docs if it's possible to filter by an empty or unset field/attribute. I tried leaving the value empty, as '', as null or undefined (I know this ain't JS, but... and even then, undefined seems to work in this scenario), to no avail.

In my scenario, I wanted to filter by domain: switch which is considered a switch, and not from another device_class (and thus, it seems that attribute just isn't present, instead of being switch).

Is that possible? If not, maybe a new unset option (which would work similarly to or, having anything inside it, but ignoring values) could be created?

ildar170975 commented 1 year ago

I tried leaving the value empty, as '', as null or undefined

Tried with all these & none, does not work. The only way seems to be using a template option - here is a way to exclude entities with a defined device_class:

type: custom:auto-entities
card:
  type: entities
filter:
  template: >-
    {{ states.binary_sensor | rejectattr('attributes.device_class','defined') | map(attribute='entity_id') | list }}
sort:
  count: 15
ncd7 commented 9 months ago

I'm very interested in this feature as well. Including or Excluding by some state or attribute value being UNSET would be incredibly useful