Lovelace Battery Entity Card

@shurik I’m using a Vera Plus hub for my zwave devices, most of the ones with batteries are exposed as binary sensors. My goal is to get rid of the battery sensor templates if possible and display any entities with batteries using the battery-entity card.

@gkrokum I do get battery icons displayed correctly. To be honest, I’m not sure about the reasons for NaN you are seeing. I’d speculate that is due to the fact that your binary sensors don’t expose “battery_level” attribute? I’ve simply installed the card, configured the attribute name and “zwave” domain, which automatically selected all zwave devices with “battery_level” attribute. I’ve played around with different attribute value to see whether the card correctly picks the devices and all seems to be working properly.

@shurik Thanks for responding again. Hmm, my binary sensors with batteries do have a battery_level attribute, I can see it in the states section of the developer tools. When I try to use my binary sensors in an entities card with battery-entity, I get the same result as I do with auto-entities, no icon and NaN for the battery percentage. The sensor battery template entities show up fine with the correct icon and battery percentage. Rather puzzling.

      - type: entities
        title: Door Battery Level
        show_header_toggle: false
        entities:
          - type: custom:battery-entity
            entity: sensor.front_door_lock_batt
          - type: custom:battery-entity
            entity: sensor.front_door_batt
          - type: custom:battery-entity
            entity: sensor.laundry_rm_door_batt
          - type: custom:battery-entity
            entity: sensor.sliding_door_batt
          - type: custom:battery-entity
            entity: binary_sensor.sliding_door

@jwelter How are you troubleshooting your issue with the battery-entity card? I don’t see any errors in home-assistant.log.

@gkrokum Maybe try to debug the card *.js file in the browser and see what’s the issue? Maybe the card is looking in a different spot or maybe binary_sensor has slightly different way to access it. But NaN means that whatever value is found is Not A Number.

@gkrokum I use the javascript console so I can see what errors are being thrown and debug the card.

It seems in my case the fold-entity-row component doesn’t like the icons, if I display into a standard entity card it’s all ok.

This got so much easier with 0.100 now all batteries have their own sensor:

type: 'custom:auto-entities'
card:
  type: 'custom:bar-card'
  columns: 1
  height: 20
  title_position: inside
  align: split
  rounding: 0px
  severity:
  - value: 30
    color: '#bf4040'
  - value: 60
    color: '#bf9540'
  - value: 100
    color: '#40bf40'
  unit_of_measurement: '%'
  width: 100%
  title_style:
    font-size: 12px
  value_style:
    font-size: 10px
filter:
  include:
    - entity_id: sensor.*.battery_level*
      state: <=90
4 Likes

@Holdestmade I’m not sure which card you’re talking about, I’ve been trying to use the lovelace-battery-entity card. I don’t see it creating any battery sensors.

However, I did finally figure out what my issue was. When you install the battery-entity card from the HACS Store, you have to install the master version and not the 0.1 version. The 0.1 version is missing the getBatteryLevel() function.That may be what is causing the issue you’re seeing @jwelter.

Any plans to make this work with a glance type card? Takes up way too much space as just entities.

2 Likes

@gkrokum
I’m using the auto-entities card as mentioned above in a few posts. v0.100+ of HA generates sensors for all sensor battery attributes.

Is there any option to enable those sensors ?
I run v 0.102 and no battery sensor has been created so far

What an awesome card. Thanks! A glance-type card would be also very nice and probably even nicer. :slight_smile:

Hey there, Thanks for this!

Is there some way to combine it with the auto-entities card, in order to populated it automatically with any sensor or binary_sensor that has `battery_level’ or similar attributes?

Here is the auto-entities card i use but it does not show the levels, just the statuses of anything that reports about battery

card:
  show_header_toggle: false
  title: Things with Battery
  type: entities
filter:
  include:
    - attributes:
        battery_level: <101
      options:
        secondary_info: null
sort:
  method: last_changed
type: 'custom:auto-entities'

But i get this on the right:
image

Hello all,

How can i get the battery_level from the sensors from xiaomi aquara?

Hello,in HA 1.06 i don’t see battery entity cards anyway.
I have no card and HA doesn’t send me any error…
Some week ago,with same configuration,i saw the card perfectly…
Any suggestion?

Same with me. Since 106 - doesn’t work

Sorry, I haven’t had much time lately to work on this, but I saw there was a pull request submitted to fix an issue with this loading in 0.106. If you update to the newer version, that should hopefully address that for you.

Just created a PR for HACS support. @cbulock Can you please create a new release with the last version of the plugin ?:pray:

After the update via HACS - now it works!

Just came across this card. Not sure how I’ve always missed it.

Had to make a change in the raw config editor as HACS adds the wrong entry. It’s should be /community_plugin/ and not /hacsfiles/

Anyway, this works great, but not so much with a glance card. Any chance of getting this to work with glance cards to reduce screen space?

Thanks.

community_plugin will be deprecated soon and the new reference should be hacsfiles instead.

I’m not sure why hacsfiles didn’t work. Have you updated HACS?