Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: Add main entity field at card's root level #131

Open
luixal opened this issue May 5, 2023 · 0 comments
Open

[FR]: Add main entity field at card's root level #131

luixal opened this issue May 5, 2023 · 0 comments

Comments

@luixal
Copy link

luixal commented May 5, 2023

Is your feature request related to a problem? Please describe.

I'm trying to use paper-buttons-row inside a button-card template (I need 7 identical cards, only entity changes). Like this:

button_card_templates:

  irrigation_button:
    entity: binary_sensor.irrigation_unlimited_c1_z1
    icon: |
      ...
    custom_fields:

      subtext: |
        ...

      row_buttons:
        card:
          type: custom:paper-buttons-row
          # ADD GLOBAL ENTITY FIELD HERE
          preset: mushroom
          base_config:
            preset: mushroom
            entity: binary_sensor.irrigation_unlimited_c1_z1 # Button-card can't set entity here!
          buttons:
            - icon: mdi:timer-play-outline
              name: |
                {% set next_duration = state_attr(config.entity, 'next_duration') %}
                {% if next_duration %}
                  {{ next_duration.split(':')[1] }}
                {% else %}
                  0
                {% endif %}
            - icon: mdi:play
              layout: icon
            - icon: mdi:cancel
              layout: icon

So button-card can't set the entity id in a custom field, but it does set entity id at a root level.

Describe the solution you'd like

Add a global entity field at card's root level (as most cards have) that is passed down to each button if no other entity is provided.

This:

          type: custom:paper-buttons-row
          entity: binary_sensor.irrgation_unlimited_c1_z1 # global entity field here, passed down to each button
          preset: mushroom
          base_config:
            preset: mushroom
          buttons:
            - icon: mdi:timer-play-outline
            - icon: mdi:play
              layout: icon
            - icon: mdi:cancel
              layout: icon

would work just as this other example:

          type: custom:paper-buttons-row
          preset: mushroom
          base_config:
            preset: mushroom
            entity: binary_sensor.irrigation_unlimited_c1_z1
          buttons:
            - icon: mdi:timer-play-outline
            - icon: mdi:play
              layout: icon
            - icon: mdi:cancel
              layout: icon

Describe alternatives you've considered

I haven't found any way of dinamically set the entity id inside base_config field.

Other solutions like lovelace-gen are too heavy, I think.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant