custom-cards / bar-card

Customizable Animated Bar card for Home Assistant Lovelace
MIT License
364 stars 52 forks source link

[Feature Request] Allow 'min' and 'max' to be an entity or float/int #124

Open firstof9 opened 3 years ago

firstof9 commented 3 years ago

I'd like to see the min and max options be able to defined via an entity (dynamic).

therealhalifax commented 3 years ago

Like to have the same, but not only entity, but also attribute of an entity.

acateon commented 2 years ago

Would love this as well!

firstof9 commented 2 years ago

It's doable via the config-template-card.

Example:

  - type: custom:config-template-card
    variables:
      max_containers: states['sensor.total_containers'].state
    entities:
      - ${max_containers}
    card:
      type: custom:bar-card
      entities:
        - entity: sensor.total_containers_running
          positions:
            icon: 'off'
          name: Running
          height: 20px
          color: green
          max: ${max_containers}
          target: 48
        - entity: sensor.total_containers_stopped
          positions:
            icon: 'off'
          height: 20px
          name: Stopped
          color: red
          max: ${max_containers}
        - entity: sensor.total_containers_paused
          name: Paused
          height: 20px
          color: darkorange
          positions:
            icon: 'off'
          max: ${max_containers}
acateon commented 2 years ago

Above worked great. Thanks.

Erestes commented 2 years ago

I'm still learning so pls forgive if a silly question... I am looking for something similar, where I would like to have the target inheriting a value from an entity called "estimated_prod"

Looking the piece of code it's basically about replacing the '40' with "estimated_prod"

` type: custom:bar-card entities:

roumano commented 2 years ago

It's doable via the config-template-card.

Example:

  - type: custom:config-template-card
    variables:
      max_containers: states['sensor.total_containers'].state
    entities:
      - ${max_containers}
    card:
      type: custom:bar-card
      entities:
        - entity: sensor.total_containers_running
          positions:
            icon: 'off'
          name: Running
          height: 20px
          color: green
          max: ${max_containers}
          target: 48
        - entity: sensor.total_containers_stopped
          positions:
            icon: 'off'
          height: 20px
          name: Stopped
          color: red
          max: ${max_containers}
        - entity: sensor.total_containers_paused
          name: Paused
          height: 20px
          color: darkorange
          positions:
            icon: 'off'
          max: ${max_containers}

I use you tips and it's working but when using it with custom:config-template-card, the animation is not working anymore.

a example , the first one, the animation is working but not in the second one :

type: entities
entities:
  - entity: sensor.circuit_1_power
    type: custom:bar-card
    animation:
      state: 'on'
      speed: '2'
  - type: custom:config-template-card
    variables:
      max_containers: states['sensor.phase_a_power'].state
    entities:
      - ${max_containers}
    card:
      entity: sensor.circuit_1_power
      type: custom:bar-card
      animation:
        state: 'on'
        speed: '2'

ps : on this example, i don't use the variable as it's just to reflect the issue with a minimal configuration.

It's a bug/limitation on custom:bar-card or in custom:config-template-card or i use it badly ?

mzurhorst commented 1 year ago

I tried to apply this for my scenario as well. I like to visualize to which extend am I utilizing the predicted solar energy on my roof.

What am I doing wrong?

type: custom:config-template-card
variables:
  forecast_today: states['sensor.forecast_pv_ertrag_ost_west'].state
entities:
  - $(forecast_today)
card:
  type: custom:bar-card
  entities:
    - entity: sensor.plenticore_energy_yield_day
      unit_of_measurement: kwh
      title: PV-Ertrag vs. Forecast
      columns: '1'
      max: $(forecast_today)