bar-card icon indicating copy to clipboard operation
bar-card copied to clipboard

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

Open firstof9 opened this issue 3 years ago • 7 comments

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

firstof9 avatar Jun 14 '21 17:06 firstof9

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

therealhalifax avatar Jun 28 '21 12:06 therealhalifax

Would love this as well!

acateon avatar Oct 18 '21 21:10 acateon

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}

firstof9 avatar Oct 18 '21 21:10 firstof9

Above worked great. Thanks.

acateon avatar Oct 19 '21 18:10 acateon

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:

  • entity: sensor.deye_daily_production max: '50' target: '40' ` Any hints/directions? I am looking at the suggestion from firstof9 but I don't know where to place it.

Erestes avatar Mar 31 '22 11:03 Erestes

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 ?

roumano avatar Sep 19 '22 09:09 roumano

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)

mzurhorst avatar Dec 30 '22 15:12 mzurhorst