maxwroc/battery-state-card

Exclude battery level of phones and smartwatches

venator85 opened this issue ยท 6 comments

Hi, how can I exclude phone and smartwatches battery levels from the list? I'd like to avoid to exclude them by their entity_id one by one, I'm wondering if it is possible to set a filter based on the device type of the battery sensor or something like that.
Do you have any hints?
Thanks

It is not possible now as currently entity doesn't have any info about the device but... this will be changing soon.

I cannot promise that this will solve your problem - it depends what kind of info exists in the device object which HA provides

Please check the next minor release

RedNo7 commented

Do you have any hints?

If you name their entity_id to always contain mobile (for example), you can exclude based on that:

exclude:
  - name: entity_id
    value: "sensor.*mobile*"

FYI in v3.2.0 you have the option to use additional data for filtering.

You can check what all your phones and smart watches have there in common by adding a debug: true in the card configuration. This will show you all the data available per entity.

For example:
image

There is a platform set to mobile_app so by adding the following filter you should be able to exclude them:

filter:
  exclude:
    - name: "display.platform"
      value: "mobile_app"

There might be the other way to do it - you just need to check what the entities which you want to exclude have in common and what is not present in all the others.

RedNo7 commented

in 3.2.0 I have this working for exclude, but not include. Is there a reason for that?

Yes, unfortunately "extended entity data" (sections like "display", "device", "area") is not available for include filters. It is because it would require me to gather properties from various sources for all of the entities. Doing it on every state update can be problematic - waste of resources.

I thought I have mentioned this somewhere in the docs but now I don't see it. I'll need to add it as it can be indeed confusing.

In the future I will think about some other approach and will add it to "include" filter too

RedNo7 commented

gotcha - thanks for clarifying!