Lovelace Battery Entity Card

Thanks!
Anyhow, im hoping that the author of this project will eventually add this feature. After all, if it’s possible to find all battery devices in one lovelace plugin, then it must be possible to do that in a different plugin.

@cbulock , big thanks for this, it works great!

I really like the looks of this one, and the simplicity!

But I’m not really sure how to set this up. Do I just paste it into the Lovelace raw config editor?

Nice is the a way to sort them by order? from full to low?

I use yaml mode and have never used gui mode, so I’m not sure how you’d do it. You do need 3 custom cards, I’ve no idea how you do that in gui mode (although I believe you can).

For me it’s in the ui-lovelace.yaml file along with the following (for the custom cards)

resources:
     - url: /customcards/github/custom-cards/vertical-stack-in-card.js?track=true
        type: js
      - url: /customcards/github/custom-cards/bar-card.js?track=true
        type: js
      - url: /customcards/github/thomasloven/auto-entities.js?track=true
        type: js

not that I’m aware of

In GUI mode, I can click “Raw Config Editor” and modify it in yaml format. I put the following in there:

  - type: module
    url: /local/battery-entity.js?v=0.1

But I’m not sure what to do next. Do I also need those additional urls?

Is there any automation that checks all the devices battery level and send a notification based on this?

I am also having a little difficulty using this module. Why isn’t the background appearing? And why aren’t the icons aligned?

Would it be possible to make it compatible with custom updater?

1 Like

I know I’m replying months later but I just discovered this card. Open battery-entity.js and find these lines:

			.good {
				color: var(--label-badge-green);
			}
			.warning {
				color: var(--label-badge-yellow);
			}
			.critical {
				color: var(--label-badge-red);
			}

Change the text next to color: under each of the categories to whatever you want. You can use a hex code. To change the green to the default dark blue, I used this: color: #44739E

Works great. Hopefully this is still actually of use to you haha.

Thanks anyway for the answer) Better late than never)) This is really helped me.

Great card, I’ve got it working with battery sensor template entities. I tried to use it with just my normal device entities like binary_sensor.front_door and it doesn’t seem to work. I’m not a programmer, but the script seems to look for entities that have a battery_level attribute. Should it work with normal device entities?

I also tried to wrap it with the custom:auto-entities card similar to an example in this thread and wildcard my battery sensor template entities, but nothing shows up in the card and I see this error: https://192.168.xxx.xxx:8123/community_plugin/lovelace-battery-entity/battery-entity.js:72:3 TypeError: this.stateObj is null.

      - type: custom:vertical-stack-in-card
        title: Battery Status
        cards:
          - type: custom:auto-entities
            card:
              type: custom:battery-entity
            filter:
              include:
                - entity_id: "sensor.*_batt"

The error seems to indicate the entity_id isn’t getting passed to the battery-entity script, but the auto-entities documentation states it works with custom cards. Any help would be greatly appreciated.

Hello,

Example of my xiaomi door sensor.

- platform: template
  sensors:
    batterie_detecteur_porte_sensor_fente_bal:
      friendly_name: 'Fente Boîte aux Lettres'
      unit_of_measurement: '%'
      value_template: >-
        {% if state_attr('binary_sensor.detecteur_fente_b_lettres', 'battery_level') %}
          {{ state_attr('binary_sensor.detecteur_fente_b_lettres', 'battery_level') | round }}
        {% else %}
          {{ states('batterie_detecteur_porte_sensor_fente_bal') }}
        {% endif %}

Exemple card battery

entities:
  - entity: sensor.batterie_detecteur_porte_sensor_fente_bal
    type: 'custom:battery-entity'
show_header_toggle: false
title: Batteries capteur porte
type: entities

Thanks @dckiller51, I already have battery sensors set up similar to yours and have them working with the custom:battery-entity in an entities card. What I’m looking for is a way to use entity filters to only show devices with battery below 25%. I started out with just trying to show all the battery sensors using custom:battery-entity wrapped in an auto-entities card. I haven’t been able to get that to work as I mentioned previously. Ideally, I’d like to figure out a way to get rid of the battery sensors altogether, but I’m not sure the custom:battery-entity supports using normal device entities instead of sensor templates.

@cbulock - should custom:battery-entity work with normal device entities like binary_sensor.front_door and extract the battery level from them?

I do this, but with a monster card, which I use for other pop-up cards when conditions are met. I find this is a far better way not to clutter my Lovelace UI. You could do the same with an entities filter card I guess. Either way no templates are required, as the monster-card can pick up attributes and/or states from your existing sensors:

- card:
     title: Low battery devices
     type: glance
  filter:
    exclude:
      - device_tracker.vatoe_s_ipad
    include:
      - entity_id: '*battery_level'
        state: < 25
      - attributes:
        battery: < 25
      - attributes:
        battery_level: < 25
  show_empty: false
  type: 'custom:monster-card'
1 Like

@gkrokum I was having the same issue. The solution is to use “options” element in “auto-entities” card (see https://github.com/cbulock/lovelace-battery-entity/issues/6):

- type: custom:auto-entities
  id: low_battery_list
  card:
    title: Low Battery Levels
    type: entities
    show_header_toggle: false
  filter:
    include:
      - domain: zwave
        attributes:
          battery_level: "< 50"
        options:
          type: 'custom:battery-entity'

1 Like

Have you tested this as your exact example doesn’t work here. Displays as NaN. Filter is getting the right sensors but it’s like the battery card isn’t picking that attribute up.

@jwelter Not sure if you are asking me. But yes, that card is displaying for me right now.

1 Like

Hmmmm. I got it working but the icons are not correct, but debugging I see them getting set correct by the javascript so might be something else going on.

@shurik Thanks a bunch for the tip. This works as far as displaying the entities that meet the filter, but I’m not getting the batttery-entity icon or the battery percentage. I’m seeing the same thing as @jwelter, NaN. Do you know if the battery-entity card will work for normal entities like binary_sensor? I haven’t been able to get it to work standalone with normal entities, just with my battery sensor templates.

      - type: custom:auto-entities
        id: low_battery_list
        card:
          title: Low Battery Levels
          type: entities
          show_header_toggle: false
        filter:
          include:
            - domain: binary_sensor
              attributes:
                battery_level: "< 90"
              options:
                type: 'custom:battery-entity'
            - domain: lock
              attributes:
                battery_level: "< 90"
              options:
                type: 'custom:battery-entity'
            - entity: binary_sensor.zcombo_bdrm2
              attributes:
                battery_level: "< 90"
              options:
                type: 'custom:battery-entity'
            - entity: binary_sensor.zcombo_bdrm3
              attributes:
                battery_level: "< 90"
              options:
                type: 'custom:battery-entity'