🔋 Lovelace: Battery state card

No, i mean to use state_map to convert the entity value Normal to 100%.
Code above does not work.

Check the state under the dev tools for those entities. You’re probably using what’s displayed on some dashboard, which could be translated. You need to use the actual state values.

1 Like

No, unfortunately this is not possible. The only solution I can propose is to set the “global”/card state map. Instead of using it per filter or group you can specify it at the configuration root and it will be applied to all your entities. I think this should solve your problem as it will only be applied when the value of the entity is “Normal” or “Schwach” (rest of the entities won’t be touched) and I assume all of such cases you want to change.

Try the config below

type: custom:battery-state-card
title: Batterie-Status
sort_by_level: asc
collapse: 10
tap_action: more-info
entities:
  - entity: sensor.lumi_lumi_sensor_magnet_aq2_battery
state_map:
  - from: 'Normal'
    to: 100
  - from: 'Schwach'
    to: 25
filter:
  include:
    - name: entity_id
      value: '*_battery*'
    - name: entity_id
      value: '*batterie*'
  exclude:
    - name: entity_id
      value: sensor.*phone*
1 Like

Is it possible to exclude entities based on the integration like this?

 exclude:
    - name: integration
      operator: '='
      value: Browser Mod

It is possible to add a filter to all available attributes of the entity. If your integration exposes such attribute to its entities then you can. You can check available attributes in “developer tools > states”. There are few additional “system” attributes which are not shown e.g. “last_changed” but “integration” is not one of them

:jack_o_lantern: Finally the v3 version is released! :jack_o_lantern:

It comes with quite a few new features, bug-fixes and various improvements.

Starting from v3 the card will work without any config. But I can imagine most of you will want to adjust it to your needs. The good news is that with this release you will have a lot more flexibility in the way how the card works.

The full list of features is available in the release notes:

Here are few examples of new features and use cases:

  • Charging state is automatically fetched from standard sources (you don’t need to configure it yourself)

  • You can have custom icons which change depending on the state (previously only color was changing)

    image

  • Multiple sorting options, now you are able to use any entity attribute value for sorting

    Below is the list of motion sensor entities sorted by state and last_changed attribute

    image

There are few breaking changes, please take a look at the documentation.

In case of any problems/bugs/suggestions feel free to create issues on github. If you like the card remember to leave a star on the repo.

Enjoy

great card - great job!!!

I want to use a very short version of this card, to show just the battery icon in a dashboard. I managed to hide the name but the percentage number I can’t find how to hide. Is there a way?

thanks in advance

You can do it via lovelace-card-mod card - by applying custom CSS styles. There was an option in the past (v1.X) to apply custom styles (natively) in this card but for some reason (don’t remember now why :slight_smile: ) I have removed it. So now lovelace-card-mod is the only way to modify/control which entity elements are shown.

I think that I saw somewhere a similar request in the past but I cannot find it now. Please create an issue on the github as it make sense to add such feature

1 Like

Thanks for the update. Happy that it now opens the entity when I click it on the battery state card!

However, I no longer see my unavailable battery entities, which is a big deal since most of my battery powered devices do not display 0% battery, but simply goes from 20% or 10% to being unavailable. How do I get this back?

I cannot help without any details from your side. Please paste here card config which you use and screenshot of entity details (state/attributes) from Developer Tools > States

it appears it was a breaking change. I needed to change

Sort_by_level: asc

to

sort:
by: “state”

Sorry

1 Like

Is it possible to have two attributes in the ‘secondary_info’ section without the ‘4 hours ago’ message turning into just a timestamp?

I have a custom attribute for battery devices which tells me which battery type they are and how many it takes so that I can easily find that battery to replace it. I was hoping to have this displayed next to the last update value.

Thanks

No, unfortunately this is not possible ATM. But this would be a good feature request - if you have an account on github please create it!

I just added the battery state card (using Battery State Card 3.0.1 on HA 2023.12.1), but I can’t really get it to work.

Adding only a type: custom:battery-state-card shows the default battery entities, but as soon as I try to add another attribute such as title: Batteries, I just get an empty card.

Any idea what I am doing wrong, or what I am missing?

Oh, it seems as soon as I add any custom attributes, the auto-generated list disappears.

I found out that this filter pretty much recreates the automatic list:

filter:
  include:
    - name: attributes.device_class
      value: battery

…and I now realized that this is clearly described in the Readme under Default card config

Can you explain (or share) the logic behind the input_boolean.batteries_low?
Do you have an automation and/or script to update this?

Thank you in advance for the excellent chips code.

Yes. Just uses the same template to count batteries that are low and then fires automation if greater than 0.

alias: Batteries Low - On
description: ""
trigger:
  - platform: template
    value_template: |-
      {{states.sensor
                  | selectattr('attributes.device_class', 'defined')
                  | selectattr('attributes.device_class', 'eq', 'battery')
                  | rejectattr('entity_id', 'in', integration_entities('mobile_app'))
                  | map(attribute='state')
                  | reject('in', ['unknown', 'unavailable'])
                  | map('int', -1) | select('le', 10)
                  | select('ge', 0)
                  | list | count
                > 0 }}
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.batteries_low
mode: single
1 Like

Hello, I don’t have anything to report, but want just to say thank you to @maxwroc :slight_smile:

1 Like

And we have a yet another release coming with bunch of new features.

Please check out a new video from BeardedThinker who mentioned this card and other battery related stuff for HA:

Happy New Year to you all!!!

3 Likes

Is there a way to hide the name?