šŸ”‹ Lovelace: Battery state card

Currently itā€™s not possible but will be in v3.0 (it is implemented already although I donā€™t have time recently to finish rest of the stuff for v3)

2 Likes

Thanks for the info! Looking forward to it! :slight_smile:

I canā€™t tell if Iā€™m doing this wrong or if itā€™s a bug, or if Iā€™m trying to request a feature. I noticed I could group things in filters by using multiple entities. However, I canā€™t seem to get the state filtering to work. I also can tell that Iā€™m using two different formats (name vs entity) but I found both between this thread and the readme. Iā€™m not sure which method is preferred/depreciated

What I would LIKE this to do is to list all devices < 30% first, then show bedroom, living room, etc. Iā€™ve included a screenshot. As you can see the ST laundry room sensor is at 16% but itā€™s WAY below the top. The multiple include grouping works perfectly for the rest of the entries.

If this isnā€™t a bug, and is actually a feature request what would REALLY be ideal is being able to show all devices under 30% then collapse immediately after.

type: custom:auto-entities
card:
  type: custom:battery-state-card
  secondary_info: last_changed
  bulk_rename:
    - from: ' Battery Level'
      to: ''
    - from: ' power'
      to: ''
filter:
  exclude:
    - entity_id: sensor.*iphone*
  include:
    - name: state
      value: 30
      operator: '<'
    - entity_id: sensor.*front_door*.power
    - entity_id: sensor.*rosie*.battery_level*
    - entity_id: sensor.*bedroom*.power
    - entity_id: sensor.*kitchen*.power
    - entity_id: sensor.*livingroom*.power
    - entity_id: sensor.*hallway*.power
    - entity_id: sensor.*guest*.power
    - entity_id: sensor.*.battery_level*
    - entity_id: sensor.*.power
    - name: attributes.device_class
      value: battery

I donā€™t use auto-entities card so I wonā€™t be able to help here. Try to ask this question on auto-entities related thread.

There is a filtering functionality supported natively on battery-state-card although it is limited (comparing to auto-entities)

Hi everyone,

Iā€™d like with this card to change the value of the exclude state, base on an input number, i try some syntax but nothing work for now. Do yo thin is possible ?

Here the example :

type: custom:battery-state-card
sort_by_level: asc
color_thresholds:
  - value: 15
    color: '#edaa98'
  - value: 85
    color: '#feeb99'
filter:
  include:
    - name: entity_id
      value: '*battery'
  exclude:
    - name: state
      value: >  
        {{ states('input_number.batterie_level') }}
      operator: '>'

I think youā€™d need to work with config-template card to achieve this.

1 Like

Ho thanks i look at that !!

This card seems really useful !

Iā€™ve tried different configuration options but havenā€™t figured this one out. Is it possible to have the sensors reporting ā€œUnavailableā€ in red? Now itā€™s in ā€œstandardā€ color.

No, itā€™s not possible ATM

Ok, thank you. No worries. At least I can stop trying. :grin:

It might be possible using card-mod. Havenā€™t tested this, though.

1 Like

IMO It wonā€™t be possible with the card-mod unfortunately.

There is no css class added in battery entity row (HTML) indicating that the state is ā€œunavailableā€. Since there are no CSS selectors which allow you to set certain styles depending on the content of the HTML element then there is no way to set the color of that element only for ā€œunavailableā€ cases.

You may be right, and Iā€™ve not played. However, it might be possible to use config.entity In a template to check the state of the entity and modify the colour accordingly.

I tried adding the gradient card version and got the following:
ā€œCustom element doesnā€™t exist: battery-state-card.ā€
Any suggestions?

That is interesting. I admit Iā€™m not very familiar with card-mod and I didnā€™t know about such option. If anyone tries and succeeds please let me know.

Hello @maxwroc ,

I would like to adapt your battery card to a zigbee link quality card.
Today my ā€œentity cardā€ looks like this :

Could you explain how to adapt it without JS skills ?

Thank you for your help

Have you checked documentation? There is an example for this use case:

The only thing which is missing in this example is that instead of color_gradient it would be better to use color_thresholds and set color/values to something more meaningful as by default it is for 0-100 range while lqi is 0-255 range.

1 Like

Thank you for your answer, I will check this.

I have been able to use the card based on the description and the forum, but had a question for a formatting option to make it show more directly what I need on top. I am loading the car in a popup. All works:
This is how it looks like:

What I would like to achieve is to have the lowest levels be in the top (uncollapsed section). For some reason, I have a 77% in the collapsed, and a few 83% on top. I have it set to asc.

Another thing I would like to see how to go about it is that some of my sensors are binary_sensors, they do not send a level, but only if battery is low.
The return is on of off. I would like to have the on sensors be also returned to the top of the list.

the weird thing is my phone does not show up and it is on the charger.

any chance this can be accomplished with this?
Here is my code, I have excluded a bunch of sensors I created to get some count of total batteries, etcā€¦

action: fire-dom-event
browser_mod:
  service: browser_mod.popup
  data:
    deviceID: this
    hide_header: false
    title: Battery Status
    size: normal
    content:
      type: custom:battery-state-card
      #title: Filters
      collapse: 6
      sort_by_level: "asc"
      secondary_info: last_updated
      entities:
        - entity: sensor.haz_main_phone_battery_level
          secondary_info: charging
          charging_state:
            entity_id: binary_sensor.haz_main_phone_is_charging
            state: 'on'
            secondary_info_text: Charging in progress
      filter:
        include:
          - name: entity_id
            value: '*_battery_level'
          - name: entity_id
            value: '*_battery'  
          - name: attributes.device_class
            value: battery
        exclude:
          - name: state
            value: 89
            operator: '>'
          - name: entity_id
            value: '*critical*'
          - name: entity_id
            value: '*low_battery'
          - name: entity_id
            value: '*with_battery'

I have a few Homematic IP window contacts and they do not give a percentage value.

These have ā€œnormalā€ what do I have to set in the state_map: so that these are displayed correctly?
I have tried something but nothing changes.

Okay i got it.