Lovelace: Bar Card

Since update my bar-card changed. It seems I am not able to change it back to the original bars.


Anyone knows what is wrong?

There is nothing wrong. Change your width to 100% and it will be as before.

Some of this might be screwed up since Iā€™ve reworked the CSS to flexbox. Iā€™m currently working another big update that will allow for multiple entities instead of a single entity per card. Iā€™ll add a fix to that release.

Release 0.1.2 adds the option to define a list of entities to display. This also works with auto-entities if you want to populate the list dynamically.

  • added entities config option, displays multiple bars based on entities list
  • added columns config option
  • title style can now still be defined when using inside title_position

@Plexat You should also be able to fix your alignment problems with these config options.

    title_style:
      text-align: left
    bar_style:
      align-items: flex-start

Examples using Auto Entities

- type: custom:auto-entities
  card:
    type: custom:bar-card
    severity:
      - value: 50
        hue: '0'
      - value: 75
        hue: '40'
      - value: 100
        hue: '120'
    title_position: inside
    columns: 3
    padding: 2px
    title_style:
      text-align: left
      font-size: 16px
    bar_style:
      align-items: flex-start
      font-size: 8px
  filter:
    include:
      - entity_id: "*_battery"

- type: custom:auto-entities
  card:
    type: custom:bar-card
    attribute: battery
    unit_of_measurement: "%"
    severity:
      - value: 50
        hue: '0'
      - value: 75
        hue: '40'
      - value: 100
        hue: '120'
    title_position: inside
    padding: 2px
    columns: 2
  filter:
    include:
      - attributes:
          battery: "<=100"
    exclude:
      - entity_id: "*_humidity"
      - entity_id: "*_pressure"
      - entity_id: "*_battery"

- type: custom:bar-card
  attribute: temperature
  unit_of_measurement: "Ā°C"
  title_position: inside
  columns: 5
  height: 200px
  min: 15
  max: 32
  target: 22.5
  width: 100%
  padding: 2px
  direction: up
  entities:
    - binary_sensor.motion_hallway
    - binary_sensor.motion_living_room
    - binary_sensor.motion_kitchen
    - binary_sensor.motion_bathroom
    - binary_sensor.motion_toilet
1 Like

Hi,

I am trying to get this going and have the bar graphs displaying correctly; but they are not named; just show the % free. Any trick to get the friendly name displayed? I checked and the devices being displayed all have friendly_names assigned.

Code below:

  - type: custom:auto-entities
    show_empty: false
    card:

        type: custom:bar-card
        attribute: battery_level
        unit_of_measurement: "%"
        severity:
          - value: 60
            hue: '0'
          - value: 80
            hue: '40'
          - value: 100
            hue: '120'
        title_position: inside
        padding: 2px
    
    filter:
        include:
          - domain: zwave
            attributes:
              battery_level: "<= 100"

Ahhh! It seems that if the bar graph itself is in the foreground on top of the title; so it gets obscured.

This seems to be new in the latest release; and on all the bar components.

Update: Seems to be a Mac Safari issue. On iOS Safari it is rendered fine; and also on Chrome on Mac itā€™s fine.

Wowā€¦you have been busy with quite a few updates I seeā€¦thanks so much for making this all possible.
Iā€™ll post a screenshot once I have the bar card up and running.

Cheers Steve Wells

1 Like

Can I make a feature request?
Would it be possible to show an icon instead of the title?

EDIT: Also, I am not a CSS expert, in fact Iā€™m not even a CSS anything, but I canā€™t get card-style to change the background.

Iā€™d like it to be transparent so that when I include a bar-card in an entity card it doesnā€™t ā€˜stand outā€™.

Iā€™ve tried allsorts of combinations (and colours) like this:
Any chance you could give an example?
Unless of course I have completely misundersttod the use of card-style :roll_eyes:

                    card-style:
#                      paper-card-background-color: 'rgba(0,255,255,0.2)'
                      background-color: 'rgba(201, 76, 76,0.5)'
#                      ha-card-background-color: 'rgba(67, 73, 84, 0.6)'                                          # Card background colour

Icon support is coming shortly. Could you show me the problem you are having with the transparency?

@Gluwc Please see below. The top is from Safari on a Mac and you can see the titles are not shown; they are there but behind the bar. (see the 48% bar in the Mac top screenshot)

The second is from IOS Safari and all is ok.

Thanks

Ok, I may be asking for something not possible but when I embed a bar into an entities card I would like the bar to appear as an entity, i.e. ā€˜flatā€™ in the entity card (and preferably - although I am sure this isnā€™t possible - the same size as it is when placed outside an entity card.

I hope this makes senseā€¦

image

Release 0.1.3 adds icon support and the ability to align items inside the bar.

  • added show_icon config option
  • added icon config option
  • added align config option
  • added off option to title_position config
  • removed bar_style config option
  • removed indicator_style config option
  • added icon_style config option
  • added value_style config option
  • fix for min/max value indicator update
  • title will now default to entity friendly name
  • removed tracker.json, should now be tracked by default

Examples on Github

@jwelter Iā€™m not entirely sure whatā€™s causing the title issue and I donā€™t have access to a mac to test safari. I did make some changes to the element layout so itā€™s possible this issue is fixed in 0.1.3. Please let me know and Iā€™ll see what I can do if itā€™s still not working correctly.

@klogg It could be possible using it in an entity card the CSS wonā€™t work for the background. Can you try setting the card_style outside of the entity card and see if it still doesnā€™t work? This example shows a custom card background.

@Gluwc I quickly tried in Safari Mac again and same issues. Both IOS and Chrome are still okā€¦

I also tried iOS safari on an iPad and it is also wrong, perhaps itā€™s a screen size thing?

What is interesting is the % shows fine; itā€™s just the title that gets obscured.

Is the style or logic for displaying the % versus title different?

Sorry Iā€™m not a JS guy; Assembler, C, C++, and Python only :wink:

@Gluwc 0.1.3 is a great update. It looks perfect with the icon and split title and I no longer want to do any further CSS styling!

Thanks!

1 Like

For anyone else having sorting issues 0.1.4 should fix this.

1 Like

Thanks for the fix! Appreciate it! :100:

Will this card work with @iantrich template card variables?

Iā€™m not sure, afaik a card doesnā€™t need to support template-card? If it does I can have a look at whatā€™s required to implement.

Itā€™s more the template card lets you use attributesā€¦ so instead of having to create template sensors, you can instead use the attribute in the same way. Itā€™s pretty coolā€¦

Thanks for considering this.

Ah yes of course this is what was sort of bothering me about using the template-card, I couldnā€™t use it as the entity value since most cards expect an entity_id there. I could add a value config option so you can set a straight up value (template) instead of an entity.

1 Like