custom-cards / bar-card

Customizable Animated Bar card for Home Assistant Lovelace
MIT License
379 stars 54 forks source link

Support use of entities in “max” and “min” properties #184

Open mreysei opened 1 month ago

mreysei commented 1 month ago
Name Type Default Description
max number or string 100 Defines maximum value of the bar using a number or a entity.
min number or string 0 Defines minimum value of the bar using a number or a entity.

And this is the working example using an entity and a number

type: custom:bar-card
positions:
  icon: inside
entities:
  - entity: sensor.maiku_salud
    name: Salud
    icon: mdi:heart
    color: '#a72741'
    unit_of_measurement: HP
    decimal: 0
    max: sensor.maiku_max_salud
  - entity: sensor.maiku_experiencia
    name: Experiencia
    icon: mdi:progress-star-four-points
    color: '#359441'
    unit_of_measurement: XP
    decimal: 0
    max: sensor.maiku_siguiente_nivel
  - entity: sensor.maiku_mana
    name: Maná
    icon: mdi:flask
    color: '#4693DB'
    unit_of_measurement: MP
    decimal: 0
    max: sensor.maiku_max_mana
  - entity: sensor.steps_daily
    name: Pasos de hoy
    icon: mdi:walk
    color: '#8646db'
    unit_of_measurement: pasos
    decimal: 0
    max: 10000

Result of such component image

If this PR does not merge because this project is not maintained, you can add a "Custom repository" in HACS with my repository link: https://github.com/mreysei/bar-card

julll190 commented 1 month ago

Hi! Please could you do the same thing to use entities in properties "from" and "to" inside the severity option, and maybe also in the "target" property? That is the only thing I miss. Thank you in advance!

mreysei commented 1 month ago

Hi @julll190, I'll give it a try.

HenrikHills commented 3 weeks ago

whenever I try to use your card I get "custom element doesn't exist: bar-card", any ideas? I have added /hacsfiles/bar-card/bar-card.js as a js-module in resources (i guess this is added automatically when i add it through HACS) ... It does work if i replace the content in "/homeassistant/www/community/bar-card/bar-card.js" with what you have here: github.com/mreysei/bar-card/blob/master/dist/bar-card.js But when i try to use a sensor as max-value it doesnt show progress on the bar:

type: custom:bar-card
entities:
  - entity: sensor.billader_session_energy
    max: sensor.billader_estimert_levert_3_fase
    min: 0
    color: "#959d90"
positions:
  icon: "off"
  name: "off"
  value: "off"
height: 10px
entity_row: true

and sensor.billader_estimert_levert_3_fase is a int-number ( 24 ) in this case ...

mreysei commented 3 weeks ago

@HenrikHills probably it is because I created a new beta version that doesn't works haha I deleted it Try to change version to 1.3.0, now works?

HenrikHills commented 3 weeks ago

@HenrikHills probably it is because I created a new beta version that doesn't works haha I deleted it Try to change version to 1.3.0, now works?

haha okay, yeah that worked perfectly, nice thanks!!