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

Styling via card_mod is no longer working #547

Open
majkers opened this issue Jun 19, 2023 · 19 comments
Open

Styling via card_mod is no longer working #547

majkers opened this issue Jun 19, 2023 · 19 comments
Labels
bug Something isn't working

Comments

@majkers
Copy link

majkers commented Jun 19, 2023

Before submitting a bug

[x ] I updated to the latest version available
[x] I cleared the cache of my browser

After updating to latest version (2.7.1) I cant style card with card_mod. In editor it seems to work but when I save it I don't see any changes:

image

image

then when I enter editor once again I have to make a single change (adding ; for example) to see my changes again but saving it produces the same result as above. It was OK in 2.6.3 version

@majkers majkers added the bug Something isn't working label Jun 19, 2023
@jumpinf00l
Copy link

I notice this myself with custom cards installed through HACS, and this doesn't seem to be isolated to vacuum-card and is possibly linked to some front end updates.

I'd suggest it's an update needing to happen to make lovelace-card-mod compatible with newer front end versions and seems to be related to lovelace-card-mod issue 281 and issue 276.

This is not to say that frontend updates are an issue; vacuum-card and lovelace-card-mod are examples of custom add-ons and are out of the scope of testing with all official Home Assistant updates.

@github-actions
Copy link

There hasn't been any activity on this issue recently. This issue has now been marked as stale and will be closed if no further activity occurs. Please, update to the latest version and check if that solves the issue.
Thank you for your contributions!

@github-actions github-actions bot added the stale label Aug 22, 2023
@philipjholm
Copy link

This is still a problem as styling that worked before isn't applied anymore. Any updates on this?

@github-actions github-actions bot removed the stale label Sep 8, 2023
@luigisax
Copy link

I have the same problem. Any updates?

@sammyh2506
Copy link

Same issue for me...

Copy link

There hasn't been any activity on this issue recently. This issue has now been marked as stale and will be closed if no further activity occurs. Please, update to the latest version and check if that solves the issue.
Thank you for your contributions!

@github-actions github-actions bot added the stale label Nov 24, 2023
@MPFGlaser
Copy link

Facing the same issue.

@github-actions github-actions bot removed the stale label Dec 10, 2023
pkissling pushed a commit to pkissling/home-assistant that referenced this issue Jan 6, 2024
@yperetz
Copy link

yperetz commented Feb 2, 2024

Facing this issue as well

@BoGnY
Copy link

BoGnY commented Mar 14, 2024

Same problem 😢

@rgavril
Copy link

rgavril commented Apr 20, 2024

Issues is still present.

@hheimbuerger
Copy link

hheimbuerger commented Jun 14, 2024

Not sure if this I've experiencing the same root cause, but your issue title applies, so I'm adding my findings here:

I'm not using the visual editor, I've used the card exclusively in YAML.
Neither any styles applied via the card_mod rules on the card itself applied, nor would setting any CSS variables in the theme have an effect.

Additionally, I've noticed that the <ha-card> element has a class of type-undefined. While other cards I've checked usually have a class that sounds like the card name, e.g. type-custom-mini-graph-card, type-tile, type-map, etc.

What worked for me as a workaround was to set the CSS variables (or other rules) via card-mod-card in the theme:

my-theme:
  card-mod-theme: my-theme

  card-mod-card: |
    ha-card.type-undefined {
      --vc-background: transparent;
      --vc-devider-color: transparent;
      --vc-spacing: 0;
    }

EDIT: I later found that setting --vc-devider-color doesn't actually work. While it does appear in the DOM, when the time comes to render the devider, the CSS variable is somehow back to its old value. I cannot figure out where it inherits the old value from.

@hheimbuerger
Copy link

I don't know if this is an expected side-effect of my workaround above, but my styling approach doesn't work the moment the vacuum is started or stopped. That removes all styling changes.

My guess is that the card deletes and recreates its shadow DOM, which also eliminates the card-mod injections.

A page reload of course fixes that, but for a status display, that's supposed to be mostly non-interactive, that's frustrating.

@guimatheus92
Copy link

Facing this issue as well

@IGOLz
Copy link

IGOLz commented Sep 9, 2024

Having the same issue

Copy link

github-actions bot commented Nov 8, 2024

There hasn't been any activity on this issue recently. This issue has now been marked as stale and will be closed if no further activity occurs. Please, update to the latest version and check if that solves the issue.
Thank you for your contributions!

@github-actions github-actions bot added the stale label Nov 8, 2024
@SeanPM5
Copy link

SeanPM5 commented Nov 8, 2024

Not stale, still a long-standing issue.

I had used card_mod so the vacuum card background color was green when vacuum in cleaning state, red when in error state, gray when paused, orange background when overdue (not vacuumed in a while), etc.

Being able to make vacuum card background color dynamic like that was very helpful to see vacuum status at a glance on my wall mount dashboard tablet. Hope the card_mod functionality can be fixed/restored at some point.

@github-actions github-actions bot removed the stale label Nov 8, 2024
@IIIdefconIII
Copy link

Im new to this card, which so far works great, i also have the same problem with the card mod, the cord mod id working perfect on like 50 other cards in my whole HA config.

I also put a feature request feature on the i hope right place

Loce the carf so far!

@goooseman
Copy link

I found a workaround by using https://github.com/thomasloven/lovelace-card-mod?tab=readme-ov-file#styling-cards-without-an-ha-card-element

It has a warning to use only if really needed, but from the first sight it seems to work, I will keep in the loop if I will find any bugs

    type: custom:mod-card
    card_mod:
      # https://github.com/denysdovhan/vacuum-card/issues/547
      style: |
        ha-card {
          animation: breathing-shadow 1.5s infinite alternate ease-in-out;
        }
        @keyframes breathing-shadow {
          0% {
            box-shadow: 0px 0px 10px 1px #FF8C00;
          }
          100% {
            box-shadow: 0px 0px 13px 3px #FF8C00;
          }
        }
    card:
      type: "custom:vacuum-card"
      entity: vacuum.roborock_qrevo_master
      # https://www.remove.bg/upload
      image: /hacsfiles/media/roborock-qrevo.png
      stats:
        default:
          - entity_id: sensor.roborock_qrevo_master_dock_error # ok, duct_blockage, water_empty, waste_water_tank_full, maintenance_brush_jammed, dirty_tank_latch_open, no_dustbin, cleaning_tank_full_or_blocked
            subtitle: Docker error?
            value_template: '{{ value | replace("_", " ") | capitalize }}'
          - entity_id: sensor.roborock_qrevo_master_filter_time_left
            unit: h
            subtitle: Filter
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
          - entity_id: sensor.roborock_qrevo_master_side_brush_time_left
            unit: h
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
            subtitle: Side brush
          - entity_id: sensor.roborock_qrevo_master_main_brush_time_left
            unit: h
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
            subtitle: Main brush
          - entity_id: sensor.roborock_qrevo_master_sensor_time_left
            unit: h
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
            subtitle: Sensors
          - entity_id: sensor.roborock_qrevo_master_mop_drying_remaining_time
            unit: min
            value_template: "{{ (value | float(0) / 60) | round(1) }}"
            subtitle: Drying
        cleaning:
          - entity_id: select.roborock_qrevo_master_mop_intensity
            subtitle: Mop intensity
          - entity_id: select.roborock_qrevo_master_mop_mode
            subtitle: Mop mode
          - entity_id: sensor.roborock_qrevo_master_cleaning_progress
            subtitle: Cleaning %
            unit: "%"
          - entity_id: sensor.roborock_qrevo_master_cleaning_time
            value_template: "{{ (value | float(0) / 60) | round(0) }}"
            unit: min
            subtitle: Cleaning time
      shortcuts:
        - name: Clean living room
          service: script.clean_living_room
          icon: "mdi:sofa"
        - name: Clean bedroom
          service: script.clean_bedroom
          icon: "mdi:bed-empty"
        - name: Clean kitchen
          service: script.clean_kitchen
          icon: "mdi:silverware-fork-knife"

P.S. seems like changing the variables does not work this way, because the variables are applied to the parent ha-card and applying them to ha-card $ vacuum-card $ ha-card does not seem to work as I see. Anyway, I'm using it to apply custom border, so for my use-case this hack is enough.

@goooseman
Copy link

Actually found even a way to overwrite variables with card_mod

    type: custom:mod-card
    card_mod:
      # https://github.com/denysdovhan/vacuum-card/issues/547
      style:
        "vacuum-card$": |
          ha-card {
            --vc-background: #17A8F4;
            --vc-spacing: 5px;
          }
        .: |
          ha-card {
            /* Add red border if there is an error */
            {% if state_attr('sensor', 'roborock_qrevo_master_dock_error') != 'ok' %}
            animation: breathing-shadow 1.5s infinite alternate ease-in-out;
            {% else %}
            animation: none;
            {% endif %}
          }
          @keyframes breathing-shadow {
            0% {
              box-shadow: 0px 0px 10px 1px #FF8C00;
            }
            100% {
              box-shadow: 0px 0px 13px 3px #FF8C00;
            }
          }
    card:
      type: "custom:vacuum-card"
      entity: vacuum.roborock_qrevo_master
      # https://www.remove.bg/upload
      image: /hacsfiles/media/roborock-qrevo.png
      stats:
        default:
          - entity_id: sensor.roborock_qrevo_master_dock_error # ok, duct_blockage, water_empty, waste_water_tank_full, maintenance_brush_jammed, dirty_tank_latch_open, no_dustbin, cleaning_tank_full_or_blocked
            subtitle: Docker error?
            value_template: '{{ value | replace("_", " ") | capitalize }}'
          - entity_id: sensor.roborock_qrevo_master_filter_time_left
            unit: h
            subtitle: Filter
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
          - entity_id: sensor.roborock_qrevo_master_side_brush_time_left
            unit: h
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
            subtitle: Side brush
          - entity_id: sensor.roborock_qrevo_master_main_brush_time_left
            unit: h
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
            subtitle: Main brush
          - entity_id: sensor.roborock_qrevo_master_sensor_time_left
            unit: h
            value_template: "{{ (value | float(0) / 3600) | round(0) }}"
            subtitle: Sensors
          - entity_id: sensor.roborock_qrevo_master_mop_drying_remaining_time
            unit: min
            value_template: "{{ (value | float(0) / 60) | round(1) }}"
            subtitle: Drying
        cleaning:
          - entity_id: select.roborock_qrevo_master_mop_intensity
            subtitle: Mop intensity
          - entity_id: select.roborock_qrevo_master_mop_mode
            subtitle: Mop mode
          - entity_id: sensor.roborock_qrevo_master_cleaning_progress
            subtitle: Cleaning %
            unit: "%"
          - entity_id: sensor.roborock_qrevo_master_cleaning_time
            value_template: "{{ (value | float(0) / 60) | round(0) }}"
            unit: min
            subtitle: Cleaning time
      shortcuts:
        - name: Clean living room
          service: script.clean_living_room
          icon: "mdi:sofa"
        - name: Clean bedroom
          service: script.clean_bedroom
          icon: "mdi:bed-empty"
        - name: Clean kitchen
          service: script.clean_kitchen
          icon: "mdi:silverware-fork-knife"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests