HASS Progress Bar Feature

December 10, 2024 ยท View on GitHub

hacs_badge GH-release GH-downloads GH-last-commit GH-code-size


A HACS integration which adds a feature to display a simple progress bar with custom colors. Can be added to any component that supports features.

Installation

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Options

Card Options

NameTypeDefaultDescription
entitystringEntity id of a sensor that goes from 0 - 100
attributestringAttribute of the tile entity that goes from 0 - 100
timetime objectTime to derive progress from
inversebooleanfalseShow the inverse percentage (ie, 85% -> 15%)
positionstringbottomProgress bar position, only accepts top or bottom
sizestring--feature-height or 3px if position is specifiedCSS value for progress bar height
colorstring--primary-colorProgress bar color. Can be any valid CSS value, a HASS CSS color variable, or the keyword meter which will change color based on progress on a gradient from 0 = red to 100 = green
backgroundstring20% opacity variant of color valueProgress bar background color. Can be any valid CSS value, a HASS CSS color variable

Time object

NameTypeDefaultDescription
initialstringAttribute or entity id of a sensor that outputs an initial time, MUST be used in conjunction with remaining or duration
remainingstringAttribute or entity id of a sensor that outputs a remaining time, MUST be used in conjunction with initial or duration
startstringAttribute or entity id of a sensor that outputs a start time, MUST be used in conjunction with end or duration
endstringAttribute or entity id of a sensor that outputs an end time, MUST be used in conjunction with start or duration

CSS Color Variables

You can pass a CSS color variable to the color option so long as you prefix it with --

There are a number of CSS color variables available in Home Assistant out of the box, such as:

  • --primary-color
  • --warning-color
  • --error-color

Your Home Assistant theme may also provide additional CSS variables.

Examples

Battery meter anchored to bottom edge:

image
type: tile
entity: binary_sensor.kitchen_sink_leak
features:
  - type: custom:progress-bar-feature
    entity: sensor.kitchen_sink_leak_battery_level
    color: meter
    position: bottom

Battery meter anchored to top edge with no background color:

image
type: tile
entity: binary_sensor.kitchen_sink_leak
features:
  - type: custom:progress-bar-feature
    entity: sensor.kitchen_sink_leak_battery_level
    color: meter
    background: none
    position: top

Semi-transparent custom background color from a variable, different from the color value:

image
type: tile
entity: binary_sensor.closet_motion
features:
  - type: custom:progress-bar-feature
    entity: sensor.closet_motion_battery_level
    color: --error-color
    background: hsla(from var(--warning-color) h s l / .2)

Cover position from attribute:

image
type: tile
entity: cover.bedroom_window
features:
  - type: cover-open-close
  - type: custom:progress-bar-feature
    attribute: current_position
    inverse: true

Time based machine cycle progress

image
type: tile
entity: sensor.dryer
features:
  - type: custom:progress-bar-feature
    position: bottom
    time:
      initial: initial_time
      remaining: remain_time

OR

type: tile
entity: sensor.dryer
features:
  - type: custom:progress-bar-feature
    position: bottom
    time:
      start: start_time
      end: end_time

TODO

  • Template value support
  • Visual editor
  • More progress bar positioning (left, right, around the card border)
  • Time value support