custom-cards / bar-card

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

[Feature request] Hide bar when sensor is unavailable #179

Open volkuhl opened 4 months ago

volkuhl commented 4 months ago

Thanks for this pretty card! Hiding bar depending on value works like a charm. Would be nice, if I can hide the bar also, when sensor is unavailable.

volkuhl commented 4 months ago

If anyone is interested, here is my workaround: Define a sensor template in configuration.yaml

- platform: template
  sensors:
    val_shelly006:
      unique_id: val_shelly006
      friendly_name: "Value Shelly006 IR-Heizung Werkstatt"
      unit_of_measurement: "W"
      value_template: >-
        {% if is_state("switch.shell_006", "unavailable") -%}
          {{ 0 }}
        {%- else -%}
          {{ states("sensor.shell_006_power")|float }}
        {%- endif %}

In the bar card, references to template-sensor instead of directly to the power sensor:

  - entity: sensor.val_shelly006
    name: Heiz.Werkstatt
    severity:
      - from: 0
        to: 0.1
        hide: true

It works well, but could be much easier to have a "switch" in the bar-card directly, instead of having to create a template for each sensor

ildar170975 commented 4 months ago
  1. Even when the bar-card is hidden by it's native hide option (for supported numerical values), the card anyway occupies some space (https://github.com/custom-cards/bar-card/issues/167).

  2. For unavailable value - you may use a standard conditional card/row to hide the whole bar-card. But the "hidden" row also occupies some space (https://github.com/home-assistant/frontend/issues/7292).

So, the only option to hide the card totally - card-mod & display: none.