🔋 Lovelace: Battery state card

Hi maxwroc, thank you so much for this wonderfull card.

This is exaclty the way i want my batteries to be showed, i’m trying to include in the less than 30% state batteries section that are not visible for the past 7 days, is it possible?

Hello. Is there any way (other than using pre-defined groups, as the idea is precisely not to have to specify a fixed list of entities) of, after applying the first filter in a macro way custom:battery-state-card, reapplying a second filter for each collapse, filtering by name of the entity. I know the code below doesn’t work, but I added it just to illustrate what i need. I tried to do it with a template but I couldn’t.

        - type: custom:battery-state-card
          title: "All Battery"
          filter:
            include:
              - name: "attributes.device_class"
                value: "battery"
          collapse:
            - name: 'Door Sensors (Qt: {count})' 
              filter:
                include:
                  - name: entity_id
                    value: '*_door_*'          
            - name: 'Temperature sensors (Qt: {count})' 
              filter:
                include:
                  - name: entity_id
                    value: '*_temp_*'          
            - name: 'Presence sensors (Qt: {count})' 
              filter:
                include:
                  - name: entity_id
                    value: '*_presence_*'          

Is it possible to change the background of this card? Can’t seem to figure it out.

You can change the line-height and I would assume you will need to reduce the line-height of the secondary info line. I haven’t figured it out myself but I would also like to do this so will report back if I figure it out

That would be great! Thanks!

Hi maxwroc, Is it possible to feed the min/max values in the Group Object sections by Helpers ?

Many Thanks,

|min|number||v1.4.0|Minimal battery level. Batteries below that level won’t be assigned to this group.|
|max|number||v1.4.0|Maximal battery level. Batteries above that level won’t be assigned to this group.|

thank you for sharing

Unfortunately group name and secondary_info support now only fixed set of keywords. But it make sense to change the logic and use “KString” which would mean you could use any value, from any other entity. I think this is something what you’re looking for, right?

You can add an issue on github with such proposal

First, thank you for this card. Brand new user. Wondering why I’m getting duplicates with the + sign. If it matters, I’m also using the Battery Notes custom integration.

Hello,

I am really liking this card. i currently have one card for all my batteries and one for our door sensors. I am trying to have the collapse field change based on the number of doors open but i keep getting this error:

Ive tried a couuple different versions of the code and i keep getting this error.

Hello all,
is there a way to place entities with ‘unknown’ state at the end of the list instead of the beginning?
Thank you

1 Like

Not sure what you mean. Did you see my example from above? 🔋 Lovelace: Battery state card - #280 by ThomDietrich

Does anyone know how to get the Secondary Info to be two lines? I can’t seem to figure out how to put a line break in. I’d prefer to have the battery type below the title but for now I’ve settled on adding it next to the name. Here is a code snippet:

type: custom:auto-entities
card:
  type: custom:battery-state-card
  gradient: true
  collapse:
    - name: Honeycomb Blinds (min {min}%, {count})
      icon: mdi:blinds
      group_id: sensor.non_tilt_blind_batteries
    - name: Tilt Blinds (min {min}%, {count})
      icon: mdi:blinds-horizontal
      group_id: sensor.tilt_blind_batteries
filter:
  include:
    - integration: battery_notes
      attributes:
        device_class: battery
      entity_id: "*blind*"
      options:
        name: >-
          {attributes.friendly_name|replace(Battery+, (Type:)}
          {attributes.battery_type_and_quantity})
        secondary_info: "Last charged: {attributes.battery_last_replaced|reltime()}"
  exclude:
    - entity_id: "*_low*"
    - entity_id: "*remote*"
show_empty: true
sort:
  method: state
  reverse: false
  numeric: true

I ended up making my own instead. I have two cards setup, one is in a popup that shows all batteries, the other is anything under 35% as shown below:

type: markdown
title: Low Battery Devices (<35%)
content: >
  {% set ignore_list = ['sensor.david_s_iphone_battery_level',
  'sensor.michelles_iphone_battery_level',
  'sensor.david_s_iphone_remote_battery_level'] %}

  {% set batteries = states.sensor
    | selectattr('attributes.device_class', 'defined')
    | selectattr('attributes.device_class', 'eq', 'battery')
    | rejectattr('entity_id', 'in', ignore_list)
    | rejectattr('state', 'in', ['unknown', 'unavailable'])
    | selectattr('state', 'le', '35')
    | sort(attribute='state') %}

  {% for battery in batteries %}
    <span style="display: inline-block; margin-bottom: 5px;">
      <ha-icon icon="mdi:battery-{{ (states[battery.entity_id].state | int / 10) | int * 10 }}" style="color: 
      {% if states[battery.entity_id].state | int < 10 %}red
      {% elif states[battery.entity_id].state | int < 20 %}orange
      {% elif states[battery.entity_id].state | int < 50 %}yellow
      {% else %}green{% endif %};"></ha-icon>
      {{ states[battery.entity_id].name }}: {{ states[battery.entity_id].state }}%
    </span><br>
  {% endfor %}
theme: Mytheme

Hello, congrats and thank you very much for this very useful card!

I’m trying to exclude devices that are charging. Is there a way to use the charging attribute/state to filter out some entities? Thanks!