Is there a way to Filter Upper and Lower Case combined in Auto Entities Card

hi i trying to get battery levels to show up in 1 single entities card

but i run in problem of some are Battery Level , Battery level, battery level

but i want to combine them all filter by the word battery level and ignore the case but i cant seem to figure it out i tried the or: as an option but then just labels everything level

how can i do this? if it can be done

Something like this should do it:

type: custom:auto-entities
card:
  type: entities
filter:
  template: |
    {{ states.sensor 
       | selectattr('name','search','Battery Level',ignorecase=true) 
       | map(attribute='entity_id') 
       | list }}

ok great that worked… i couldnt find it on the auto entities github page… be nice if it was on there … but thank you

The card documentation can’t cover all the possible template options. For that you search the jinja template documentation.

ah ok ill google that…
oh another question if you have an apostrafee how do you search that

Michelle’s

how can i search when there is a ` i tried double qoutes but didnt work

and last question if you wanna do a “and” search

so “battery” and “iphone” so if i only wanted to search for battery word and iphone word but in any order… how can i do that…

i googled jinja if this is it i skimmed it still confusing for me
Template Designer Documentation — Jinja Documentation (3.1.x)

You escape single quotes with another single quote (silly but true) you escape double quotes with a backslash \

filter:
  template: |
    {{ states.sensor 
       | selectattr('name','search', 'Michelle''s',ignorecase=true) 
       | map(attribute='entity_id') 
       | list }}

ANDing selections (must contain both battery AND iphone):

filter:
  template: |
    {{ states.sensor 
       | selectattr('name','search', 'battery',ignorecase=true) 
       | selectattr('name','search', 'iphone',ignorecase=true) 
       | map(attribute='entity_id') 
       | list }}

ok the battery and iphone one worked

the ‘Michelle’‘s’
didnt work for me… displays nothing
i tried backslash you mentioned but i probably did wrong i tried
\Michelle’s\
\Michelle\\s\

but it didnt wanna work for me that ‘s’ to get Michelle’s to work

Try this:

filter:
  template: |
filter:
  template: |
    {{ states.sensor 
       | selectattr('name','search', 'Michelle\'s',ignorecase=true) 
       | map(attribute='entity_id') 
       | list }}

I was confusing YAML escaping with jinja escaping.

ah ok that worked had to take out the 1st filter didnt like both.
and thats ok you cant know everything… my html coding days ended 20 yrs ago its surpassed me now all this new stuff i so behind lol… i appreciate the help…
least thats working to break things down

i been playing around with the help you given so i learned about the backslash for apostraphe
and i learned
| selectattr(‘name’,‘search’, ‘battery’,ignorecase=true)
| selectattr(‘name’,‘search’, ‘iphone’,ignorecase=true)
| map(attribute=‘entity_id’)

that makes it a AND

how do i do a OR
i did try

or:
sof if you wanted to list
Michael or Michelle as example… all in the entity card

Search accepts regular expressions (regex). This should return the entity id for any entity name that contains ‘battery’ OR ‘iphone’.

   {{ states.sensor 
       | selectattr('name','search','(battery|iphone)',ignorecase=true) 
       | map(attribute='entity_id') 
       | list }}

ok great that is working too… i did try to make another card as i learning this great card
i made

type: custom:auto-entities
card:
  type: entities
  title: Battery Level's
filter:
  template: |
    {{ states.sensor 
       | selectattr('name','search', 'Battery',ignorecase=true) 
       | map(attribute='entity_id') 
       | list }}
  include:
    - name: "*Battery-Level*"
  exclude:
    - integration: "*remote*"
    - entity_id: "*voltage*"
    - state: discharging
title: Battery Level's
sort:
  method: state
  reverse: false

so it excludes the remote home assistant, discharging, voltage

but i have these Xiaomi devices that tell the temperature… i use esp32 device as a bluetooth server… but is there a way to strip off the bluetooth servers name?
the entity shows up
Bluetooth Server #3 (House) Front Door Humidity (Xiaomi)

but in esphome each entity is really called
Front Door Humidity (Xiaomi)
Front Door Temperature (Xiaomi)

is there a way to strip off the front part.
Bluetooth Server #3 (House)

so only
Front Door Battery-Level (Xiaomi)

will show up or is that something i have to figure out in esphome to do?

and here is my code in esphome

esphome:
  name: bluetooth-server-2
  friendly_name: "Bluetooth Server #3 (House)"

  - platform: atc_mithermometer
    mac_address: "A4:C1:38:15:ED:F9"
    temperature:
      name: "Front Door Temperature (Xiaomi)"
      id: test3
      # Reset Counter to 0  When There Is An Update From Device
      on_value:
        then:
          lambda: |-
            id(counter3) = 0;  
    humidity:
      name: "Front Door Humidity (Xiaomi)"
      id: test3b
    battery_level:
      name: "Front Door Battery-Level (Xiaomi)"
      id: test3c
    battery_voltage:
      name: "Front Door Battery-Voltage (Xiaomi)"
      id: test3d

so id like the name to show up not espname + name and name doesnt show up in the entity ids properties the setting for name is blank

is there a way when you do the esphome… and the friendly name for the esp device it doesnt slap the esp friendly name in front of the name.