question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto add entities based on wild card search (or device-class) and add filer option to exclude some of them

See original GitHub issue

Finally, a battery card!

Any change your card can get a wild card for entities and attributes? And an exclude value option (some sensors like FIbaro can also be wired, the battery value is then defaulted to 4)

Cheers.

My cuurent setup:

card:
  show_header_toggle: false
  title: Sensor Battery Status
  type: entities
filter:
  exclude:
    - state: '4'
  include:
    - entity_id: sensor.fib_*_battery_level
      options:
        style: |
          :host {
          --paper-item-icon-color: 
           {% if states(config.entity)|float <= 20 %} 
             red
           {% elif states(config.entity)|float <= 35 %}
             orange
           {% else %}
             var( ---state-icon-color )
           {% endif %}
           ;
           }
sort:
  method: state
  numeric: true
  reverse: false
type: 'custom:auto-entities'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
mdegat01commented, Apr 27, 2020

FYI @Tom-ahawk this card works with auto-entities. I’m using it right now like this:

- card:
    show_header_toggle: false
    title: Battery levels
    type: 'custom:battery-state-card'
    color_gradient:
      - '#ff0000'
      - '#ffff00'
      - '#00ff00'
  filter:
    exclude:
      - state: Ok
    include:
      - entity_id: sensor.*_battery_level
      - entity_id: sensor.*_battery_health
  show_empty: false
  sort:
    method: state
    numeric: true
  type: 'custom:auto-entities'

So @maxwroc its up to you if you want to implement this yourself in your card or simply point people to auto-entities as a solution to this problem.

1reaction
maxwroccommented, Apr 26, 2020

Interesing idea with the wildcard entity search! I’m slightly concerned it can be a bit slow if you have a lot of entities in your HA.

HA updates the cards “every time” (probably it is throttled) when any antity state changes (even if it’s not used in the card). So in this case I would need to iterate over the entire collection of entities and get their state. But since you’re saying that you have almost similar setup for the other card I will give it a try.

If it is ok perfwise I will add it in similar way as you have it in your example. If not I could do some kind of discovery mode in which list of found entities will be printed on the card - you would be able to copy it over to the configuration.

I don’t see any problems with state filtering so I will add it for sure

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto-entities - Automatically fill cards with entities
include: A list of filters specifying which entities to add to the card. exclude: A list of filters specifying which entities to remove...
Read more >
Wildcard characters allow searching for patterns and variations
Expand search results to match any non-space character. The system supports both single-character and multiple-character wildcards.
Read more >
Create and manage device groups - Microsoft Learn
Specify the matching rule that determines which device group belongs to the group based on the device name, domain, tags, and OS platform....
Read more >
Manual Chapter: Adding Entities to a Security Policy - AskF5
The pure wildcard (*) is automatically added to the security policy so you do ... URL, and flow parameters as any value type,...
Read more >
Solved: Re: Dashboard Wildcard Filtering ("not" Exceptions)
In the Dynatrace dashboard Data explorer is there a way to add wildcard exception filtering? Example, filter to show me all of something...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found