šŸ”‹ Lovelace: Battery state card

I have left entity or entities fields required (at least one was required) in v1.3.0 which was a mistake corrected in v1.3.1. Please update the card or use the following (as you cannot leave it blank):

entities: []
1 Like

I really like what you have done here, thanks for your hard work.

Would it be possible to include auto-entities integration or capability for battery attributes?

Thanks. Sorry but I donā€™t know what you mean exactly by ā€œinclude auto-entities integrationā€? In v1.3.0 I have added similar functionality that exists in auto-entities.

You can automatically include/exclude entities based on any attribute/property (filters documentation).

Apologies.

Auto-entities is another custom card, for battery information I can use it to show entities with attribute battery level below a certain threshold. I canā€™t get it to show the actual battery attribute value.

With your card I can show the battery level but not all the entities that display using Aut-entities.

I hope that is clearer.

Please look here as people were able to use my card together with auto-entities. Though in this case you cannot specify properties for individual entities (e.g. specifying that the value should be extracted from attribute). That is why I have added similar functionality to my card and you donā€™t need to use auto-entities any more.

If you have some entities which have battery level in attribute you can add them explicitly (look at example here - ā€œOutside temp. sensorā€)

Hello,

Iā€™m using HACS and managed to install this plugging along with the auto-entities one. I very new to lovelace and while Iā€™ve tried to configure this, there is definitely something missing, but I really donā€™t have much idea how lovelace works. Could somebody provide some guidance for dummies on how to include this card, along with auto-entities.

Many thanks in advance everyone!

Question: why do you need to use auto-entities?

Have you tried to use the example from here?

It is hard to help if you donā€™t tell what you want to achieve.

Hi Maks,

Would you consider adding an option to change the secondary-info colour? I tend to use var(--secondary-text-color) rather than my primary colour. I know it can be done with card-mod but last time I tried that it messed up all my cards so I would rather not have to install it just to do one small change!

No worries if not, completely understand.

Hi, I think I was mixing up stuff. I thought that for the card to dynamically display the information I wanted, I needed to use auto-entities. I feel dumb. Sorry.

Iā€™ve managed to get my card working and it is now displaying battery information!! thanks a million!

Iā€™m however trying to filter out some entities that I donā€™t want to see, and Iā€™m failing at accomplishing what I want. Iā€™ve opened this issue providing all the information: https://github.com/maxwroc/battery-state-card/issues/74

If you would rather prefer for me to deal with this here rather than in Github, I can close that issue and post the information here.

A milion of thanks in advance,

Yes I have in mind couple of additional settings for colors. I want to add an option to add completely custom styles. This way everyone can adjust the card exactly to their needs. If you have a github account feel free to add a feature request - this way I wonā€™t forget it and you will be notified when this is added.

1 Like

It should be working with the configuration what you have. Maybe there is a bug. I will take a look.

Github is actually better as I check it more often than the forum. Plus you will be getting notifications (e.g. when bug is fixed).

Sounds great, thanks Maks!

I was about to add the request, but I see there is already one there for the secondary_info colour, so I +1ā€™d and subscribed to that instead.

https://github.com/maxwroc/battery-state-card/issues/56

Hope thatā€™s sufficient?

Ok next quite big update was just released (v.1.4.0). Two things worth to mention:

  1. Groups
    • You can use group IDs instead of individual entities - if you have groups defined on HA side
    • You can have a multiple collapsing/folding groups (previously you were having just a single one). Entities can be assigned to them manually or based on their value (battery level)
  2. Custom styles
    Allow you to adjust the view to your exact needs - like colors, sizes etc. Below the example of glance-view

Hope you guys like it!

4 Likes

Hello!

Yes!

I used this example: https://github.com/maxwroc/battery-state-card/issues/1#issuecomment-634522011
and it works for a part of my devices with batteries.
I am searching for a possibility to also show this battery_level of an entity:

Together with auto-entities I showed them with the following code:

            filter:
              include:
              - attributes:
                  battery_level: "<=100"

How can I add them with your card?

First you need to include all which have this attribute and then exclude if the value doesnā€™t meet the condition:

  filter:
    include: # filters for auto-adding
      - name: attributes.battery_level 
        # you don't specify the value so all entities with battery_level attrib will be included 
    exclude: # filters for removing
      - name: attributes.battery_level
        value: 100

edit: in this case if you use ā€œstateā€ as name in ā€œexcludeā€ item it should work as well

Let me know if it works

Not it doesnā€™t. If I use your original code from the other page:

        filter:
          include: # filters for auto-adding
            - name: entity_id # entities which id ends with "_battery_level"
              value: "*_battery_level"
            - name: attributes.device_class # and entities which device_class attribute equals "battery"
              value: battery
          exclude: # filters for removing
            - name: state # exclude entities above 99% of battery level
              value: 99
              operator: ">"

I am getting this:

When I am adding these lines:

        filter:
          include: # filters for auto-adding
            - name: entity_id # entities which id ends with "_battery_level"
              value: "*_battery_level"
            - name: attributes.device_class # and entities which device_class attribute equals "battery"
              value: battery
            - name: attributes.battery_level 
              # you don't specify the value so all entities with battery_level attrib will be included 
          exclude: # filters for removing
            - name: state # exclude entities above 99% of battery level
              value: 99
              operator: ">"
            - name: attributes.battery_level
              value: 100

I am getting only these:
Bildschirmfoto 2020-07-09 um 19.01.22

It is hard for me to help as I donā€™t know what is the exact expectation and what is the actual state of the entity which youā€™re hoping to see.

The first example which you have it is fine in terms of filters as there are no entities with state > 99. Text states donā€™t match the ā€œ> 99ā€ condition so they are included as well.

The second example seems to be really an issue if for the previous one was returning more results. The second one should be matching more entities not less. But again it is hard for me to tell what might be the reason.

First of all if you have a github account please add the bug issue there - it will be easier to track such specific thing. If you donā€™t and donā€™t want to create it there we can try to solve the issue via this thread on this forum.

To be able to help and check why entity is missing I would need to know what is the entity exact state and properties: take a screenshot of the entity from developer tools / states e.g.:


And paste your complete config for my card.

FYI I have tested both of your filter sections and they do work for me

Here is the entity:
Bildschirmfoto 2020-07-13 um 22.48.11

Maybe it is a problem that the state is ā€œoffā€.

I want to see every battery_level of any device that has a battery, regardless if this is an attribute or a sensor.

Yes, that is really strange. And I tested many different configurations but none of them is working as expected.

The problem is that I will be not at home for the next time, so I can not really test anything. I will write again when I will be back.

Yes, I think in this specific case the ā€œstateā€ on othe exclude filter list messes up stuff for you - it depends though on rest of your configuration. That is why I have asked about the rest of your card config.

In general if all the entities which you want show up, when you donā€™t have exclude filters, then we can be sure that exclude part is the problem.

If that is the case please check if the state is correctly rendered for all of them (numeric value or something what you expect to see as batter state).

Then if you want to filter out the ones with ā€œ100ā€ just use the following in exclude section

exclude:
  - name: state
    value: 100
1 Like

Thank you for your help!

You see the whole card-config in my above message.
Here is the one I tested now without the include filters:

      - type: 'custom:battery-state-card'
        title: Filters
        sort_by_level: "asc"
        bulk_rename:
          - from: "Battery Level" # simple string replace (note: "to" is not required if you want to remove string)
            to: "sensor"
          - from: "/\\s(temperature|temp)\\s/" # regular expression
            to: " temp. "
        entities:
          # entities requiring additional properties can be added explicitly
        -   entity: sensor.temp_outside_battery_numeric
            multiplier: 10
            name: "Outside temp. sensor"
        filter:
          include: # filters for auto-adding
            - name: entity_id # entities which id ends with "_battery_level"
              value: "*_battery_level"
            - name: attributes.device_class # and entities which device_class attribute equals "battery"
              value: battery
            - name: attributes.battery_level 
              # you don't specify the value so all entities with battery_level attrib will be included

Now I get:

The ones that are displayed are fine and the state is correct for all of them!

But there are the climate ones that are not working. A picture of one of the entities is in my last message. I switched one of them to heat and not to off, but that didnā€™t change anything.