piitaya / lovelace-mushroom

Build a beautiful Home Assistant dashboard easily
Apache License 2.0
3.71k stars 340 forks source link

[Bug]: Template Card removes Card-Mod entry #1328

Closed davidrustingha closed 17 hours ago

davidrustingha commented 10 months ago

Requirements

Current Behavior

I was working on a new card to show me the waste collector days. I'm making use of the card-mod features for a custom background, blinking colors and icons when a bin will be collected today.

The first card in my horizontal-stack gets their card-mod entry deleted, the rest is still fine. When in edit mode the cards do what i expect them to do, but when I save the card and then reenter the edit mode the card mod entry is gone on the first card.

This also happens when I use a mushroom-template card without a horizontal/vertical-stack and doesn't happen when I use another card

Expected Behavior

No response

Steps To Reproduce

In a normal lovelace dashboard create a new card. Use the code below in a new card. Hit save. The card should show the correct colors etc. Hit edit. The card background color disapears. Hit Show Code Editor. The card-mod entry has been removed from the card, the rest still works as expected.

Context

YAML state

type: custom:mushroom-template-card
primary: PLASTIC
secondary: Over {{ state_attr('sensor.meppel_pmd', 'Days_until') }} dagen.
icon: mdi:trash-can-outline
entity: sensor.meppel_pmd
icon_color: |
  {% if state_attr('sensor.meppel_pmd', 'Days_until') == 3 %}
    orange
  {% elif states('sensor.meppel_morgen') == 'pmd' %}
    red
  {% elif states('sensor.meppel_vandaag') == 'pmd' %}
    green
  {% endif %}
layout: vertical
multiline_secondary: true
card_mod:
  style: |
    @keyframes blink {
      0% {
        border: 
          {% if state_attr('sensor.meppel_pmd', 'Days_until') == 3 %}
            solid 3px orange;
          {% elif states('sensor.meppel_morgen') == 'pmd' %}
            solid 3px red;
          {% elif states('sensor.meppel_vandaag') == 'pmd' %}
            solid 3px green;
          {% endif %}
      }
      100% {
        border: solid 3px var(--primary-background-color);
      }
    }

    ha-card {
      animation: 
        {% if state_attr('sensor.meppel_pmd', 'Days_until') == 3 %}
          blink 2s linear infinite;
        {% elif states('sensor.meppel_morgen') == 'pmd' %}
          blink 2s linear infinite;
        {% elif states('sensor.meppel_vandaag') == 'pmd' %}
          blink 2s linear infinite;
        {% else %}
          none;
        {% endif %}
      background: #16181c;
      --primary-text-color: rgb(242, 242, 242);
      --secondary-text-color: rgb(166, 166, 166);
      }
tap_action:
  action: none
hold_action:
  action: none
double_tap_action:
  action: none

Environment

- Browser: Chrome
- HA Version: core:2024.1.0 supervisor:2023.12.0 os:11.2 frontend:20240103.3
- Mushroom: 3.2.2

Anything else?

No response

davidrustingha commented 10 months ago

FYI: it still happens on v3.2.3 (I didnt expect it to be fixed already but just so you have all the information). I haven't updated to core2024.1.1 since i've seen a few bugreports with that.

stephane-r commented 10 months ago

Hi @davidrustingha

Are you sure the problem is from mushroom ? I've same problem, but i've try to downgrade mushroom to previous version, the problem is stay.

davidrustingha commented 10 months ago

Hi @stephane-r Yeah im pretty sure the issue comes from Mushroom. I have tried it with diffrent cards and it only happens when using the mushroom template card.

If you have an idea or need me to check something let me know!

stephane-r commented 10 months ago

After latest update, it fixed for me

piitaya commented 9 months ago

Weird, I can not reproduce it. I'm not sure it's a Mushroom issue but many people use card mod with template card and don't have this issue.

Sectorchan commented 8 months ago

Can you even select any Mushroom cards from the "new" menu?

jack3308 commented 2 months ago

I'm having a similar issue with the "view_layout" key used for the Custom Layout Card. card_mod seems to stick around, but view_layout gets removed everytime I go into edit the card and then leave again.