Pulsing battery charge indicator

Make the charge bar in a tile card pulse (fade in-and-out) while charging.

Install the absolutely awesome “Custom Features for Home Assistant Cards”. Then:

  • Add a “custom features row” for the battery state
  • Add a “slider” that is based on the battery percentage
  • Edit the slider to have the Interaction be “Nothing” (you only want this to show the value, not change it)
  • Edit the Appearance to be “Flat” (so it doesn’t look like a control)
  • Edit the Appearance CSS to have the following code for animating the bar based on whether it is charging. (I use the “sensor.car_charger_power” but you could also use a “binary_sensor.is_charing” or anything else.)
@property --color {
  syntax: '<color>';
  inherits: true;
  initial-value: orange;
}

@keyframes pulse-color {
  from { filter: brightness(110%); }
  to   { filter: brightness(70%); }
}

:host {
  {% if states("sensor.car_charger_power")|float(0.0)>10.0 %}
  animation: pulse-color 2s linear(0, 0.25, 1) infinite alternate;
  {% endif %}
}

Now when the charging is active (sensor.car_charger_power > 10.0) the charge bar will pulse brighter and darker to show you it is charging. Subtle but gratifying.
-David

2 Likes

Appreciate the sharing of this. Somehow I’ve managed to be unaware of the Custom Features card.
Just added a couple of battery sensors. As you state, subtle but a nice addition to the dashboard.
Thanks!

The best feature (in my opinion) is that you can use it for selectors to get buttons for each mode. So I can have a selector with “Full” “Cozy” and “Off” to have a 3-way control for a light rather than just “on”/“off”.

-David