thomasloven / lovelace-layout-card

🔹 Get more control over the placement of lovelace cards.
MIT License
1.05k stars 125 forks source link

Assign a 'card type' when using auto entities (rather than defaulting to the Entity card) #228

Closed Mattie432 closed 1 year ago

Mattie432 commented 1 year ago

hi, You've written a very useful set of modules. Thanks.

I'm looking for the option to set the card type of each entity in the grid when using auto-entities. Use case being that i want to dynamically list all scenes for a room, but I want to use a custom card for each entity's display. Currently the readme states: If no card type is explicitly specified for the entries, the [Entity](https://www.home-assistant.io/lovelace/entity/) card will be used.

Example: https://i.imgur.com/7DEg29o.png but i'd like them to render like this: https://i.imgur.com/VunmOVu.png

Mattie432 commented 1 year ago

To update, it turns out this is possible tho incompletely documented. I'm including my configuration below in case that helps others in the future.

Primary/Seconday/Icon/etc are all settings available on the custom:mushroom-template-card card.

type: custom:auto-entities
filter:
  include:
    - domain: scene
      area: Hallway
      options:
        type: custom:mushroom-template-card
        primary: >-
          {{states.this.entity_id.attributes.friendly_name|replace("Group |","",
          1)}}
        secondary: ''
        icon: >
          {% set icon = states.this.entity_id.attributes.icon %} {% if icon is
          defined %}
            {{icon}}
          {% else %}
            mdi:lightbulb-on
          {% endif %}
        layout: vertical
        icon_color: >
          {% set icon = states.this.entity_id.attributes.friendly_name %} {% set
          icon_lower = icon|lower%} {% if 'white' in icon_lower %}
            grey
          {% elif 'amber bloom' in icon_lower %}
            amber
          {% elif 'autumn gold' in icon_lower %}
            #c6e866
          {% elif 'bright' in icon_lower %}
            #FFF43D
          {% elif 'concentrate' in icon_lower %}
            #FFDE00
          {% elif 'dimmed' in icon_lower %}
            #FFCD00
          {% elif 'energise' in icon_lower %}
            #a8a8a8
          {% elif 'lake mist' in icon_lower %}
            red
          {% elif 'read' in icon_lower %}
            #FFCD00
          {% elif 'relax' in icon_lower %}
            #e1edea
          {% elif 'sundown' in icon_lower %}
            #E271A0
          {% else %}

          {% endif %}
  exclude: []
card:
  type: custom:layout-card
  layout_type: custom:grid-layout
  cards: []
  layout:
    max_width: 400
    grid-template-rows: auto
    grid-template-columns: 33% 33% 33%
    place-self: center
show_empty: true
Mikey887 commented 1 year ago

Spent the last two hours trying to work this out