thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.2k stars 111 forks source link

Mushroom entity cards with auto-entities #310

Open DEADSEC-SECURITY opened 1 year ago

DEADSEC-SECURITY commented 1 year ago

Hey guys, I'm trying to make auto-entities use mushroom cards but for it to work I need to use vertical-stack and I was wondering if its possible to configure it to populate the entities with a custom card inside a vertical-stack?

broyuken commented 1 year ago

I would like this as well, what was your workaround? Could you share the code please?

justinbyoung commented 1 year ago

I was pulling my hair out trying to do the same thing. I finally got it to work. Here is how I got auto-entities working with vertical-stack and the mushroom-update-card to show me what updates are available.

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  include:
    - entity_id: update.*
      state: 'on'
      options:
        type: custom:mushroom-update-card
        entities:
          - this.entity_id
kiragengis commented 1 year ago

I loved the solution, but there is any way to click on the entity and behaves as a switch? If it is on, make it off.

kiragengis commented 1 year ago

I loved the solution, but there is any way to click on the entity and behaves as a switch? If it is on, make it off.

I have completed this through this code:

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  include:
    - entity_id: light.*
      state: 'on'
      options:
        type: custom:mushroom-update-card
        entities:
          - this.entity_id
        tap_action:
          action: call-service
          service: homeassistant.turn_off
          service_data:
            entity_id: this.entity_id

I am now looking on how to do it with template. This is what I am trying to do:

type: custom:auto-entities
card:
  type: entities
filter:
  template: "{{ expand('group.Lights_House') | selectattr('state','eq','on') | map(attribute='entity_id') | list }}"
  type: custom:mushroom-update-card
  tap_action:
    action: call-service
    service: homeassistant.turn_off
    service_data:
      entity_id: this.entity_id
gislis2 commented 1 year ago

I am now looking on how to do it with template. This is what I am trying to do:

type: custom:auto-entities
card:
  type: entities
filter:
  template: "{{ expand('group.Lights_House') | selectattr('state','eq','on') | map(attribute='entity_id') | list }}"
  type: custom:mushroom-update-card
  tap_action:
    action: call-service
    service: homeassistant.turn_off
    service_data:
      entity_id: this.entity_id

@kiragengis Try this:

type: custom:auto-entities
filter:
  template: |-
    {% for light in expand('group.Lights_House') if light.state == 'on' -%}
      {{
        {
          'type': 'custom:mushroom-update-card',
          'entity': light.entity_id
        }
      }},
    {%- endfor %}
show_empty: true
card_param: cards
card:
  type: grid
  columns: 1
  square: false

Can't help you with the 'tap_action' I'm afraid

kiragengis commented 1 year ago

I received help and I get this working:

type: custom:auto-entities
card:
  type: grid
  columns: 1
  square: false
  title: Lights On
card_param: cards
filter:
  template: |-
    {% for x in expand('group.Lights_House') | selectattr('state','eq','on') %}
    {{- 
    {
      'type': 'custom:mushroom-entity-card', 
      'entity': x.entity_id,
      'primary_info': 'state',
      'secondary_info': 'name',
      'icon': icon,
      'icon_color': 'amber',
      'vertical': true,
      'tap_action': {
        'action': 'call-service',
        'service': 'homeassistant.turn_off',
        'target': { 'entity_id': x.entity_id }
       }
    }
    -}},{%- endfor -%}

Now, when I tried something like this, it did not work:

type: custom:auto-entities
card:
  type: grid
  columns: 1
  square: false
  title: Lights On
card_param: cards
filter:
  template: |-
    {% for x in expand('group.Lights_House') | selectattr('state','eq','on') %}
      {% if 'fan' in x.entity_id %}
        {% set icon = 'mdi:fan' %}
      {% else %}
        {% set icon = 'mdi:lightbulb' %}
      {% endif %}
    {{- 
    {
      'type': 'custom:mushroom-entity-card', 
      'entity': x.entity_id,
      'primary_info': 'state',
      'secondary_info': 'name',
      'icon': icon,
      'icon_color': 'amber',
      'vertical': true,
      'tap_action': {
        'action': 'call-service',
        'service': 'homeassistant.turn_off',
        'target': { 'entity_id': x.entity_id }
       }
    }
    -}},{%- endfor -%}