šŸ”¹ fold-entity-row - Hide away stuff in entities cards

IĀ“m looking for a similar thing:

Inside an entities card I use several fold-entitiy-row cards each containing one custom:auto-entities card. At the end I want to visualize all open devices, sorted by doors, windows, garage doors etc.

Example for one part:

  - type: custom:fold-entity-row
    head:
      type: section
      label: Fenster (Windows)
    padding: 0
    open: true
    group_config:
      state_color: true
    entities:
      - type: custom:auto-entities
        card:
          type: entities
          title: ''
          state_color: true
          show_header_toggle: false
        entities: []
        filter:
          include:
            - domain: binary_sensor
              attributes:
                device_class: window
              state: 'on'
              options:
                secondary_info: last-changed
        show_empty: false
        unique: true
        sort:
          method: state
          reverse: false

As you can see when there are no devices open, the fold-entity-row section takes a lot of space.

:question: How to hide a fold-entity-row, if thereĀ“s currently no entity (delivered by custom:auto-entities) inside it to show?

Of course I could just nest all the custom:auto-entities cards inside one entities card and simply use the title option. BUT the title takes just too much space, while text size of the fold-entity-row header ist just perfect. And I try to avoid using card-mod/mod-card to hack title size. Any other idea or recommendation?

Update: I implemented my own idea (:upside_down_face:) and replaced fold-entity-row by auto-entities, and modded auto-entities cards title with card-mod. So still 2 great @thomasloven frontend tools in use, I only lost the original fold feature of fold-entity-row of course - as I donĀ“t need that here itĀ“s okay. Final result and pretty happy with that:

Anyway / to sum up:

IĀ“d strongly vote for a ā€œhide header if thereĀ“s no content to showā€ option for fold-entity-row!

Hey,
is there also a way I can integrate my logbook here?

type: logbook
entities:
  - script.justin_sleep_modus
  - script.justin_wach_modus
hours_to_show: 24

Hi there,
first off all I have to say that I love this card. Good work. Thank you.

Now I stumbled upon a small Problem. I have the following card set up:

type: entities
entities:
  - type: custom:fold-entity-row
    head: light.hue_haus
    open: false
    entities:
      - entity: light.hof_links
      - entity: light.hof_rechts
      - entity: light.hue_dach_einfahrt
title: Hausbeleuchtung

As you can see i have a general switch light.hue_haus which turns on all the entities listed below.
Is there any way to rename the switch in the header? it shows as ā€œhue_hausā€ and Iā€™d like to show it as ā€œHausbeleuchtungā€ like in the title.
Unfortunately I cant rename the entity due to my naming scheme.

any help would be appreciated. keep up the good work.

many thanks from Germany

Chris

p.s.:
i tried:

type: entities
entities:
  - type: custom:fold-entity-row
    head: light.hue_haus
      label: Haus
    open: false
    entities:
      - entity: light.hof_links
      - entity: light.hof_rechts
      - entity: light.hue_dach_einfahrt
title: Hausbeleuchtung

with no effect.

Is there a way to make the carrot that expands the row larger?

By using card-mod

Hi Thomas, this card is great! Thanks!
I was wondering if there is a way to ā€œoverrideā€ the tap_action? I am trying to acomplish a foldable menu. If i click on the header line (e.g. Ground Floor) it should navigate to view 1, but if I click on the expand button, it should unfold and show me the rooms in it which I can then also navigate to e.g. ā€œ1#kitchenā€
The second part works, what I am not able to do, is trigger navigation by clicking on the label.
Any help would be much appreciated.
Cheers

Hi Allā€“

Iā€™m not certain if this is even possible. I tried multiple configs and variations of the ā€œ- type: customā€ per the Misc tricks Github link, but I think what Iā€™m going for might be beyond the scope of what using ā€œcustomā€ will process.

What Iā€™d like to do is insert a few Conditional Cards within fold-entity-row(s) (essentially, replacing the list of ā€œentities:ā€). The bottom section of the attached screenshot contains controllers for automatic door answering for deliveries. I donā€™t have the system on all the time but I do utilize the top sectionā€™s controllers regularly. In the interest of both aesthetics and preventing an accidental trigger, Iā€™d like to hide these settings as the default.

The reasoning for Conditional Cards is:

  • Received should only display when Scheduled is not off,

  • both Scheduled and Received should be hidden if Auto-Buzz is turned off.

  • Scheduled alternates between an input-select and an input-number because I have settings for ā€œUnlimitedā€, ā€œAuto-Welcomeā€ and off ā€¦ it flips to the numeric instance when I select ā€œCustomā€ from the dropdown (which makes for a cleaner interface that doesnā€™t have a hard limit on the schedule and allows for more reliable incrementing/decrementing).

Am I wishing for the impossible or might there be a way to achieve this with fold-entity-rows?
Thanks for any guidance you may be able to offer.

Great capability. Thank you. The same thing happened to me as with ā€œdressoir_allā€ image. The examples provided show this structure, so itā€™s easy to see how someone could think that the first line is required. After futzing around, I noticed this post.

Would someone please at least tell me if it is indeed possible or not to do what Iā€™m asking so that I may figure out an alternative plan? My heart is really set on what I described but if itā€™s not possible for folding entities to contain conditional cards, Iā€™ll move on. Thank you.

sure, a fold can contain anything you can regularly show on a row, what that you tried didnā€™t work?

the options are endless. you could even template the whole card config, or use state-switch, or, as a last resort (more bare bones than the other options), the core conditional card :wink:

Hi allā€¦
Do you have any idea why I risk changing the color of the LABEL in firefox, but in chrome it doesnā€™t work?

Thanks!

      - type: custom:fold-entity-row
        head: 
          type: section
          label: "Show Settings"
          style: |
            .label {
              margin-left: 0px;
              color: red;
              }

Just to say i love this mod !

Because styles should not be used by ā€œjust copy-pasteā€ method.
Always use Code Inspector and see if the style is applied or not.
In your particular case - use !important.

1 Like

hello,

is it possible to align the card in the fold card the same side left?

type: entities
card_mod:
  style: |
    ha-card {
      margin: 0px 0px 0px 0px;
      background: none;
      border: none!important;
      
    } 
entities:
  - type: custom:fold-entity-row
    head:
      type: section
      label: Alle Lampen
    entities:
      - type: custom:auto-entities
        show_empty: true
        card:
          type: entities
        filter:
          include:
            - group: group.active_lights

EDIT

okay, who can read is at an advantage

padding: 0px

does the job

In lovelace I have this:

  - type: entities
    show_header_toggle: false
    entities:
      - type: custom:fold-entity-row
        head: group.sensor_power_entities
        icon: mdi:power
        format: precision0

This is working, and simply results in
Schermafbeelding 2022-03-28 om 10.22.29

group.sensor_power_entities
is holding a series of sensors with the current power.

I also created a sensor to calculate the total power consumed by all these entities together.

sensor:
  - platform: template
    sensors:
      power_getotaliseerd:
        friendly_name: Power Plugs en Modules Total
        unit_of_measurement: W
        device_class: power
        icon_template: mdi:plus-box-outline
        value_template: >
          {{expand('group.sensor_power_entities')|map(attribute='state')|map('float')|sum|round(0)}}

Now, instead of ā€˜onbekendā€™ I would like to display the value of sensor.power_getotaliseerd

This makes sense, before unfolding I already see the total power.
But I canā€™t find a way how to show this because head is being used to populate the entities list after unfolding in this case, and not to define what to show on this particular line.

you could use the power sensor as head, and add the filter group option with auto-entities

like

  - type: custom:fold-entity-row
    head: sensor.power_getotaliseerd
    entities:
      - type: custom:auto-entities
        card:
          type: entities
        filter:
          include:
            - group: group.sensor_power_entities
              options:
                secondary_info: last-changed

I have that exact setup here:

  - type: custom:fold-entity-row
    <<: *scroll
    head: sensor.calculated_bruto_verbruik
    padding: 0
    entities:
      - type: custom:auto-entities
        card:
          type: entities
          card_mod: *mod
        filter:
          include:
            - group: group.switches_sensors_actueel
#              options:
#                secondary_info: last-changed
        sort:
          method: state
          numeric: true
          reverse: true

showing like:

though I do find the Sensor in the Head less appealing than the bolder section label tbh.

Thanks !
I only added this to the filter:

              exclude:
                - state: '< 1'
                - state: 'unavailable'

since my groups do have a lot of power-entities where the plug is not in use or not available.

Final result

1 Like

Iā€™m also wondering about using templating within this card. Iā€™m trying to make a fold-entity-row thatā€™s only open if an entity is ā€œonā€ ā€” is that possible? So far itā€™s not giving me errors, but itā€™s also opening the row regardless of the entityā€™s state:

type: custom:fold-entity-row
open: "{% if is_state('light.mainfloor', 'on') %} true {% else %} false {% endif %}"
head:
  entity: light.mainfloor
  name: Main Floor
  icon: mdi:sofa
entities:
  - type: custom:fold-entity-row
    head:
      entity: light.livingroom
      name: Living Room
      icon: mdi:sofa
    entities:
      - entity: light.livingroom_ceiling
        type: custom:slider-entity-row
        name: Ceiling Light
        state_color: false
        hide_when_off: true
        toggle: true
      - entity: light.brass_floor_lamp
        name: Floor Lamp
        type: custom:slider-entity-row
        state_color: false
        hide_when_off: true
        toggle: true
      - type: divider
  - type: custom:fold-entity-row
    head:
      entity: light.kitchen
      name: Kitchen
      icon: mdi:chef-hat
    entities:
      - entity: light.kitchen_sink
        type: custom:slider-entity-row
        name: Kitchen Sink
        state_color: false
        hide_when_off: true
        toggle: true
      - entity: light.breakfast
        type: custom:slider-entity-row
        name: Breakfast Table
        state_color: false
        hide_when_off: true
        toggle: true
      - type: divider
  - type: custom:slider-entity-row
    entity: light.chandelier
    name: Dining Room
    icon: mdi:silverware
    state_color: false
    hide_when_off: true
    toggle: true
  - type: custom:slider-entity-row
    entity: light.entry
    name: Entryway
    icon: mdi:door-open
    state_color: false
    hide_when_off: true
    toggle: true

Possible with config-template-card

Sometimes it could be great to allow / disallow to fold / unfold items.
This may be achieved by using card-mod.
The idea is to hide a chevron button:

type: entities
title: hidden chevron
entities:
  - entity: input_boolean.test_boolean
    name: lock unfold
  - type: custom:fold-entity-row
    card_mod:
      style: |
        div#head ha-icon {
          {% if is_state('input_boolean.test_boolean','on') %}
          display: none;
          {% endif %}
        }
    head:
      type: section
      label: More details...
      card_mod:
        style: |
          .label {
          {% if is_state('input_boolean.test_boolean','on') %}
          color: var(--disabled-text-color) !important;
          {% endif %}
          }
    padding: 15
    open: false
    clickable: false
    entities:
      - entity: sun.sun
      - entity: sun.sun

How it works:

  1. When the chevron is not hidden it can be used to fold/unfold items:
    image
    image

  2. When the chevron is hidden it cannot be used:
    image

  3. But there is a problem: if the items are unfolded and the chevron is hidden - then the items continue to be unfolded (which is wrong):
    image

Ideally when setting the ā€œlocking conditionā€ to ā€œonā€ we should unfold the items too. But I do not know any method to achieve this.

Surely we may use a config-template-card to set an ā€œopenā€ option dependingly on the same condition as described above. But then we have to list all entities in the ā€œentitiesā€ option of the config-template-card (which may be cumbersome).
Here is an example:

type: entities
title: hidden chevron
entities:
  - entity: input_boolean.test_boolean
    name: lock unfold
  - type: custom:config-template-card
    variables:
      OPEN: states['input_boolean.test_boolean']
    entities:
      - ${OPEN.entity_id}
      - sun.sun
    row:
      type: custom:mod-card
      card_mod:
        style:
          fold-entity-row $: |
            div#head ha-icon {
              {% if is_state('input_boolean.test_boolean','on') %}
              display: none;
              {% endif %}
            }
      card:
        type: custom:fold-entity-row
        head:
          type: section
          label: More details...
          card_mod:
            style: |
              .label {
              {% if is_state('input_boolean.test_boolean','on') %}
              color: var(--disabled-text-color) !important;
              {% endif %}
              }
        padding: 15
        open: '${OPEN.state === "on" ? false : true}'
        clickable: false
        entities:
          - entity: sun.sun
          - entity: sun.sun

image
image

How it works:

  1. If some condition is FALSE:
  • the chevron is visible and the items may be folded / unfolded;
  • the initial state is ā€œitems are unfoldedā€ (open: true).
  1. If some condition is TRUE:
  • the chevron is hidden and the items cannot be folded / unfolded;
  • the state is ā€œitems are foldedā€ (open: false).

A disadvantage of this method is ā€œitems should be unfolded by defaultā€.

Related issues: