🔋 Lovelace: Battery state card

I’m glad to hear that you like it. Please give me some more details, like exact version of the card and HA, additionally paste your card config.

There was an issue with secondary info which was fixed in 1.6.2 (released yesterday). The problem was only with showing last-changed/updated time.

The exact reason of missing text was that translations have changed in recent HA releases and I had to switch to the new ones. So the fix for the new HA probably broke the older one (let me know if that is your case).

Dear maxwroc,

thank you very much for your reply.

A couple of minutes ago I shut down my Home Assistant virtual machine in order to make a backup. Once finished, I restarted Home Assistant and now the secondary_info is shown again. What’s really weird is that a “normal” restart within Home Assistant did not fix the problem because I have tried that several times yesterday. However, a complete reboot seems like to have the problem fixed.

Kind regards!

1 Like

Hi @maxwroc,

Congratulations on your great work! I’ve been using your card for several months already and I’m happy camper! I recently needed to switch the configuration of my RFXTRX hub and now I keep detecting rfxtrx devices constantly. Guess what? those new devices make a mess of my card and I frequently find things like this:

Screen Shot 2020-12-08 at 17.23.53

As per your documentation, I believe I can’t filter out these results

Note: Include filters should rely on static entity properties. E.g. you should not add include filter which checks the state property. Include filters are processed only once - when page is loaded (to minimize perf impact).

Any chance I could remove the Unavailable devices?

thanks

Hi,
Udklip1
Is there a way to round the battery level ?

I assume you see these entities because you have the include filter set up. Please paste your config otherwise it is usually harder to help.

Have you tried sth like the following:

filter:
  include: # filters for auto-adding
    ...
  exclude: # filters for removing
    - name: state
      value: Unavailable

This is not currently possible in the card. You can do it via template sensor.

value_template: "{{ states('sensor.your_entity_id') | round(0) }}"

Here is more complete example from my configuration:

It would be easy to add such functionality. You can create an issue on github for it

1 Like

I got this working after 4 restarts LOL, No idea what the issue was in the end.

Ill leave this here anyway, might help someone :slight_smile:

Love this frontend add-on btw. Is there a way to sort by level and sort by name?

type: 'custom:battery-state-card'
title: Battery levels
sort_by_level: asc
entities:
  - sensor.z_wave_motion_sensor_battery_level_3
  - sensor.z_wave_motion_sensor_battery_level_2
  - sensor.z_wave_motion_sensor_battery_level
  - sensor.water_sensor_water_main_power
  - sensor.water_sensor_furnace_room_power
  - sensor.visonic_mct_340_e_power
  - sensor.visonic_mct_340_e_fc1d110b_power
  - sensor.visonic_mct_340_e_f70a120b_power
  - sensor.visonic_mct_340_e_e5523e0b_power
  - sensor.visonic_mct_340_e_be37110b_power
  - sensor.visonic_mct_340_e_97db110b_power
  - sensor.visonic_mct_340_e_90473e0b_power
  - sensor.visonic_mct_340_e_86453e0b_power
  - sensor.visonic_mct_340_e_7b4f3e0b_power
  - sensor.visonic_mct_340_e_631b110b_power
  - sensor.visonic_mct_340_e_4e493e0b_power
  - sensor.visonic_mct_340_e_3017110b_power
  - sensor.visonic_mct_340_e_2e423e0b_power
  - sensor.visonic_mct_340_e_070e110b_power
  - sensor.upstairs_office_closet_power
  - sensor.samjin_button_a7b60001_power
  - sensor.recessed_door_window_sensor_battery_level
  - sensor.patio_door_battery_level
  - sensor.motion_sensor_upstairs_office_power
  - sensor.motion_sensor_mb_window_power
  - sensor.motion_sensor_mb_closet_power
  - sensor.motion_sensor_living_room_power
  - sensor.motion_sensor_kitchen_window_power
  - sensor.motion_sensor_kitchen_cabinets_power
  - sensor.motion_sensor_evelyns_room_power
  - sensor.motion_sensor_downstairs_office_power
  - sensor.garage_door_lock_battery_level
  - sensor.front_door_sensor_battery_level_2
  - sensor.front_door_lock_battery_level_2
  - sensor.evelyns_room_bedtime_button_power
  - sensor.bosch_isw_zpr1_wp13_power
  - sensor.bosch_isw_zpr1_wp13_6cdc4cb4_power

Yeah, same feature was suggested somewhere in this thread already. It’s not possible at the moment but I plan to add it in the nearest future. You can track it via this issue on github

Currently I’m rewriting the card and want to finish it before adding new features.

2 Likes

Really liking the card.

Does anyone know if it’s possible to have multiple dropdowns?

I can only seem to get one dropdown working.

I was hoping to have something like:

  • battery 1
  • battery 2
  • Dropdown - doors
    • door sensor battery 1
    • door sensor battery 2
    • door sensor battery 3
    • door sensor battery 4
  • Dropdown - temperature
    • temp sensor battery 1
    • temp sensor battery 2
    • temp sensor battery 3
  • Dropdown - switches
    • switch sensor battery 1
    • switch.sensor battery 2

Thanks

Yes it is possible and you can achieve it in two ways. You can list entities in the group individually or if you have the group defined in your HA config you can use instead.

I think that the sample in the cod is pretty clear: https://github.com/maxwroc/battery-state-card#battery-groups

If not please let me know and I will try to update it and add some more details.

type: 'custom:battery-state-card'
title: Battery state card
sort_by_level: asc
collapse:
  - name: 'Door sensors'
    icon: 'mdi:door'
    entities: # explicit list of entities
      - sensor.bedroom_balcony_battery_level
      - sensor.main_door_battery_level
      - sensor.living_room_balcony_battery_level
  - name: 'Another group'
    icon: 'mdi:light'
    entities: # explicit list of entities
      - sensor.sensor1
      - sensor.sensor1

I think very useful option is to set the condition when the entity should be removed from the group and appear on the top of the list (ungroupped). Use min option - look in the doc.

This is how it looks on my dashboard (entities where battery level is below 75% are moved out of the groups):
image

Thanks for the pointers! Got that just the way i’d imagined now.

I don’t have the attribute “Battery State” how do I add it?

its only available if the device allows it, not all do

Hi All and thanks to the author of the card :slight_smile: !

I have an issue with icon color when using either color gradient or threshold. I am only getting green color or orange.
I have made a copy/paste of the custom color threshold and color_gradient examples but I only have green or orange.

See below with code and screenshoot

type: custom:battery-state-card
title: "Custom color thresholds"
thresholds:
  - value: 35 # applied to all values below/equal
    color: "#8fffe1"
  - value: 45 # applied to all values below/equal
    color: "#8fbbff"
  - value: 60 # applied to all values below/equal
    color: "#978fff"
  - value: 100 # applied to all values below/equal
    color: "#fe8fff"
entities:
  - sensor.multi_sensor_battery_level
  - sensor.switch_mini_1_battery_level
  - sensor.tradfri_on_off_switch_1_battery_level
  - sensor.tradfri_on_off_switch_2_battery_level
  - sensor.tradfri_on_off_switch_3_battery_level
  - sensor.openclose_10_battery_level

battery state card ressource is loaded.
I have the iOs theme by @basnijholt installed, HA image running on an odroid C4.
system view from supervisor tab

Any hint on what I might be missing or doing wrong please ?

thanks !

There was a bug in documentation (color threshold yaml example). I have fixed it now.

Please replace thresholds: with color_thresholds: in your yaml and it should do the trick :wink:

Hi Maks, thanks :slight_smile: working now. I am now trying to add battery charging status for iphone and ipad. Documentation is ok in this regard ?

Thanks.

It doesn’t work this way. I won’t be confirming here if everything, piece by piece, is properly documented :wink: You have found documentation bug which was there for a year, I think, and no one noticed it before. If you experience any issues with the examples given in the documentation just let me know and I will take a look. (but I hope everything will work fine). Good luck

Is the only way to include entities in the ‘collapse’ is to list them explicitly? I’ve tried all sorts of permutations for config and can’t get the wildcard search to work. Could just be me.

I was hoping to group battery levels by their levels except for 0-25%. So the end results would be similar to:

Battery Entity 1 - 10%
Battery Entity 2 - 21%
Collapse 1 - 26-50%
Collapse 2 - 51-75%
Collapse 3 - 76-100%

Documentation:

image

type: 'custom:battery-state-card'
filter:
  include:
    - name: entity_id
      operator: matches
      value: '*_battery_level'
    - name: attributes.device_class
      operator: =
      value: battery
sort_by_level: asc
title: Groups based on the level
collapse:
  - name: "Batteries 30-40%"
    secondary_info: "{count} batteries"
    min: 30
    max: 40
  - name: "Batteries 40-90%"
    secondary_info: "{count} batteries"
    min: 40
    max: 90
  - name: "Batteries 90-100%"
    secondary_info: "{count} batteries"
    min: 90
4 Likes