Lovelace: Multiple entity row

only been playing with this card today but and its great but is there a way to fix the column sizes for example.

Im trying to get all the info in for the teams I follow and Ive tried various ways but it all does NOT fit.

If it fits on my laptop, it doesnt fit on the android app.
I would like the fixture, date and if possible how many days but I know the space is limited

Thanks

Martyn
image

I have a value 5900 that I want to show as 5.900. I can use the format: kilo, which gives me 5.9, or format: precision3, which gives me 5,900.000. But I can’t seem to combine kilo with precision.
How to solve this?

I corrected the code above, thanks.

I would like to use that code to make the low battery icon appear only when the battery is low. In the image below you can see how it looks now but it is static… I am trying to figure out how to hide it when the battery level is > 35%.

custom:multiple-entity-row has a hide_if function that works as desired if I just have the battery percentage show, but doesn’t work if I try to hide the icon.

I’am not sure, but it seems multiple entity row can’t read attributes if sensor is in unknown state.
For example I have sensor.mysensor with state = none( in HA it will be as unknown).
But mysensor have attributes and they are alive (in developer tools or in entiti card).
Is it bug or that’s how it should work?

Use card-mod for the icon with display: none attribute if level >35%.

1 Like

I’ve spent hours on this and can’t figure it out… Hopefully I am closer (thanks to your input).

The if statement correctly resolves to none; in the template tester but it doesn’t work when I try to use it in this context. If I add card_mod: before styles, it still doesn’t work, and the icon turns blue rather than red as it is now so it makes things seemingly worse.

type: entities
entities:
  - type: custom:slider-entity-row
    entity: light.front_porch_light
    toggle: true
  - entity: binary_sensor.front_porch_motion_sensor
    type: custom:multiple-entity-row
    entities:
      - icon: mdi:battery-alert-variant-outline
        styles:
          '--paper-item-icon-color': red;
          display: |
            {% if states('sensor.front_porch_motion_sensor_battery') | int(0) >= 35  %}
              none;
            {% endif %}
  - entity: light.driveway_lights
  - entity: switch.garage_light
    icon: mdi:lightbulb
  - type: custom:slider-entity-row
    entity: light.patio_light
    toggle: true
  - entity: binary_sensor.patio_motion_sensor
    type: custom:multiple-entity-row
    entities:
      - entity: sensor.patio_motion_sensor_battery
        name: Battery
        hide_if:
          above: 35
  - entity: light.backyard_light
    icon: hass:track-light

  1. This is not card-mod. Check examples in the card-mod Community thread & on GitHub.
  2. You are trying to use template inside the styles option - which is not supported.
  3. Not all CSS attributes may be changed by using the styles option.

I have, but can’t find anything that applies. Also, I am trying to hide the icon that doesn’t have an entity associated to it, not the main entity icon so I wonder whether card-mod can handle that. Either way, I am about to give up :frowning:

type: entities
entities:
  - entity: binary_sensor.front_porch_motion_sensor
    type: custom:multiple-entity-row
    entities:
      - icon: mdi:battery-alert-variant-outline
        styles:
          '--paper-item-icon-color': red;
type: entities
entities:
  - entity: input_boolean.test_boolean
  - type: custom:multiple-entity-row
    entity: sun.sun
    card_mod:
      style: |
        div.entity:nth-child(2) state-badge {
          color: red;
          {% if is_state('input_boolean.test_boolean','on') %}
          display: none;
          {% endif %}
        }
    entities:
      - entity: sun.sun
      - icon: mdi:car
      - entity: sun.sun
    show_state: false

изображение
изображение

This was already explained:
card-mod thread → 1st post → link at the bottom → link for multiple-entity-row

1 Like

@Ildar_Gabdullin Thank you for your patience. I had seen that code but did not recognize it as what I needed. While I don’t know why, I found that I have to split the color and icon hiding code in two sections div.entity:nth-child(1) state-badge and div.entity:nth-child(2) state-badge otherwise the icon changes color but remains visible. I believe that started happening when I opted to make the battery xx% show when low as added info. Anyhow, the code below works as desired. Thank you again for all your help even though I found it cryptic due to my limited knowledge on this topic. :slight_smile:

type: entities
entities:
  - type: custom:multiple-entity-row
    entity: binary_sensor.front_porch_motion_sensor
    card_mod:
      style: |
        div.entity:nth-child(1) state-badge {
          color: red;
          {% if states('sensor.front_porch_motion_sensor_battery') | int(0) > 35 %}
          display: none;
          {% endif %}
        }
        div.entity:nth-child(2) state-badge {
          color: red;
        }
    entities:
      - entity: sensor.front_porch_motion_sensor_battery
        hide_if:
          above: 35
        name: false
      - icon: mdi:battery-alert-variant-outline


1 Like

Probably we may have a bug non-optimal code here.
The battery state is “column #1”, the icon is “column #2”.
When the state > 35 → then the column#1 is hidden (hide_if) and the “column #2” becomes a “column #1”.
Then this code:

        div.entity:nth-child(1) state-badge {
          color: red;
          {% if states('sensor.front_porch_motion_sensor_battery') | int(0) > 35 %}
          display: none;
          {% endif %}
        }

will work ONLY for the icon (state-badge) in the “column #1” - which ONLY happens when “>35”.
Then that “color: red” line is useless - the icon is not displayed.
And I guess that this code may be rewritten as:

        div.entity:nth-child(1) state-badge {
          display: none;
        }

But this must be tested.

This code:

        div.entity:nth-child(2) state-badge {
          color: red;
        }

will ONLY work for the icon in the “column #2” - this ONLY happens when “<= 35”.
So the icon will be always red - hope this is what you need.

NOTE:
Even w/o card-mod this may be achieved:

  - type: custom:multiple-entity-row
    entity: sun.sun
    entities:
      - entity: input_number.test_level_1
        name: false
        format: precision0
        hide_if:
          above: 35
      - icon: mdi:car
        entity: input_number.test_level_1
        name: false
        hide_if:
          above: 35
        styles:
          --paper-item-icon-color: red
    show_state: true

изображение

Shorter with yaml anchors:

  - type: custom:multiple-entity-row
    entity: sun.sun
    entities:
      - &ref_battery
        entity: input_number.test_level_1
        name: false
        format: precision0
        hide_if:
          above: 35
      - icon: mdi:car
        <<: *ref_battery
        styles:
          --paper-item-icon-color: red
    show_state: true

As you can see we can add an entity for the icon - just be used for the hide_if algorithm.

@Ildar_Gabdullin Wow! I learned more from this latest post than hours searching for answers! Thank you so much, both examples you provided work perfectly!

type: entities
title: Show battery icon when low V2
entities:
  - type: custom:multiple-entity-row
    entity: binary_sensor.front_porch_motion_sensor
    card_mod:
      style: |
        div.entity:nth-child(1) state-badge {
          display: none;
        }
        div.entity:nth-child(2) state-badge {
          color: red;
        }
    entities:
      - entity: sensor.front_porch_motion_sensor_battery
        hide_if:
          above: 35
        name: false
      - icon: mdi:battery-alert-variant-outline
  - type: custom:multiple-entity-row
    entity: binary_sensor.front_porch_motion_sensor
    entities:
      - entity: sensor.front_porch_motion_sensor_battery
        name: false
        format: precision0
        hide_if:
          above: 35
      - icon: mdi:battery-alert-variant-outline
        entity: sensor.front_porch_motion_sensor_battery
        name: false
        hide_if:
          above: 35
        styles:
          '--paper-item-icon-color': red
    show_state: true

battery < 35

battery > 35

I have yet to try the YAML anchors but I am excited to learn they exist as it simplifies updating and reusing this code! I appreciate all the time you took to help me out!

Edit: I implemented the anchors and it now I have one less edit to make when I reuse this code for all my battery sensors. I’ll read up on them to see if there are other uses!

  - type: custom:multiple-entity-row
    entity: binary_sensor.front_porch_motion_sensor
    entities:
      - &ref_battery
        entity: sensor.front_porch_motion_sensor_battery
        name: false
        format: precision0
        hide_if:
          above: 35
      - icon: mdi:battery-alert-variant-outline
        <<: *ref_battery
        styles:
          '--paper-item-icon-color': red
    show_state: true

Btw:

  1. Anchors should be used in yaml mode (not storage mode) mainly - the HA editor may replace anchors with the code.
  2. Consider using a decluttering card if many similar rows for different batteries are required.

P.S. In your example “35” is a fixed hardcoded value.
If you need to use some input_number for it (which is supposed to be displayed on some “Settings” page) - then card-mod or config-template-card are your choices.

1 Like

As you point out in #1 I noticed that once I save, the anchors are indeed replaced. I will save the code in a text file for easy reference.

I’ve seen the decluttering card, but have not attempted using it yet. I was afraid I might end up complicating the code (yes by simplifying it…) so much I break it and don’t know how to go back.

The idea of decluttering card is the same as for a “procedure” in a high-level programming language - “one code is used in many places”.
You may create a nice multiple-entity-row with many icons & complex code - then put it inside a decluttering template, then use this template for all your batteries.
As I said before, the code may become cumbersome if you decide to use input_number instead of hard-coded “35” (just an example).

1 Like

I have tested for several hours but unfortunately no code so far worked. Perhaps someone can help me.
This is my starting point:

  - entity: binary_sensor.fenster_og_kind_nord
    type: custom:multiple-entity-row
    name: OG Kind
    state_header: Nord
    state_color: true
    entities:
      - entity: binary_sensor.fenster_og_kind_west_links
        name: West links
        state_color: true
      - entity: binary_sensor.fenster_og_kind_west_rechts
        name: West rechts
        state_color: true

This shows the window state of a room with three windows. Once one window is open I want the icon display in a different color. This only works for the main entity but not for the two sub entities.

Is there a way to prevent such an unwanted wrap?

scrot20220329205739

  - entity: sensor.sm_a320fl_battery_level
    type: custom:multiple-entity-row
    show_state: false
    name: false
    icon: mdi:battery
    entities:
      - entity: sensor.sm_a320fl_battery_level
        name: Smotty
      - entity: sensor.sm_t830_battery_level
        name: GlaxS4
      - entity: sensor.sm_t733_battery_level
        name: GlaxS7
      - entity: sensor.p00c_battery_level
        name: Zenny
      - entity: sensor.battery_tz200
        name: TZ200
        hide_if: unknown
styles:
  width: 9999px

Because sub-entities are presented as “states” instead of “icons”.
Use “icon: true” for these sub-entities - icons will be displayed instead of states (if you really need this).

Ok I see. Is there a possibility to display an icon which is not linked to an entity and which can be colored according to the state of all three windows?