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

Card-mod card backgrounds do not update #163

Closed
4 tasks done
tomlut opened this issue Nov 26, 2021 · 8 comments
Closed
4 tasks done

Card-mod card backgrounds do not update #163

tomlut opened this issue Nov 26, 2021 · 8 comments

Comments

@tomlut
Copy link

tomlut commented Nov 26, 2021

My Home Assistant version: 2021.11.5

My lovelace configuration method (GUI or yaml): GUI

What I am doing: Changing card-mod themes with an automation.

What I expected to happen: Card backgrounds to change.

What happened instead: Card backgrounds do not update until the page is refreshed. Behaviour was introduced in card-mod v3.1.1 and has been absent since this issue was previously resolved here: #66 (comment)

Day theme:
Screenshot 2021-11-26 at 20-45-54 Administration - Home Assistant

Night theme selected but card backgrounds do not update:
Screenshot 2021-11-26 at 20-46-05 Administration - Home Assistant

After a page refresh the backgrounds are displayed correctly:
Screenshot 2021-11-26 at 20-46-19 Administration - Home Assistant

Minimal steps to reproduce: See config below

The issue occurs when changing the theme with an automation. Only the card backgrounds fail to update.

automation

- alias: 'Select Theme'
  trigger:
  - platform: state
    entity_id: input_select.select_theme
  action:
    service: frontend.set_theme
    data:
      name: "{{ states('input_select.select_theme')|lower }}"

input select

select_theme:
  name: Select Theme
  options:
  - Day
  - Night

themes

day:
  card-mod-theme: day
  card-mod-card: |
    ha-card.top-level-card {
      border: solid 1px var(--primary-text-color);
      background: linear-gradient(rgba(147, 171, 202, 1), rgba(255, 255, 255, 0.6) 56px, rgba(255, 255, 255, 0.6) 100%); #url("/local/background/card_bg_Day.png");
    }

night:
  card-mod-theme: night
  card-mod-card: |
    ha-card.top-level-card {
      border: solid 1px var(--secondary-text-color);
      background: linear-gradient(rgba(57, 103, 158, 1), rgba(0, 0, 0, 0.6) 56px, rgba(0, 0, 0, 0.6) 100%); #url("/local/background/card_bg_Night.png");
    }

Error messages from the browser console: none


By putting an X in the boxes ([]) below, I indicate that I:

  • Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).

  • Have made sure I am using the latest version of the plugin.

  • Have followed the troubleshooting steps of the "Common Problems" section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.

  • Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.

@tomlut
Copy link
Author

tomlut commented Nov 28, 2021

This only appears to be an issue in Firefox. Safari and Chrome load the theme as expected.

@gurbyz
Copy link

gurbyz commented Nov 28, 2021

Hi. I got the same behavior, but for view backgrounds (not updating the background when theme is changed by automation). This is since 2021.11.5 but since that upgrade I also upgraded to card-mod 3.1.1 and I switched from a lovelace.resources.module to the recommended frontend.extra_module_url. I use Chrome. Same behavior on IOS app.

day:
  card-mod-theme: day
  card-mod-root: |
    hui-view {
      background: none !important;
    }
    ha-app-layout {
      background-position: center !important;
      background-size: cover !important;
      background-repeat: no-repeat !important;
      background-image: url("/local/images/wallpaper_triangles.jpg") !important;
      background-attachment: fixed !important;
    }
   ... etc ...

Night theme is same, but with other image. I update via service: frontend.set_theme.

@gurbyz
Copy link

gurbyz commented Nov 28, 2021

I did find a clue here. Someone had background issue when only having the frontend.extra_module_url and not the lovelace.resources.module. But having the module loaded by lovelace.resources.module as well as frontend.extra_module_url didn't help for me.

@tomlut
Copy link
Author

tomlut commented Apr 9, 2022

@thomasloven I hate to be a pest but can anything be done about this?

Like gurbyz above using both loading methods does not fix this for me.

@tomlut
Copy link
Author

tomlut commented Apr 23, 2022

Turning on "Automatically close connection" in my profile negates this issue as the page reloads when I switch to the tab showing home assistant.

@gurbyz
Copy link

gurbyz commented Apr 26, 2022

Turning on "Automatically close connection" in my profile negates this issue as the page reloads when I switch to the tab showing home assistant.

I personally can't use this solution because I get the issue on a dashboard monitor that is in kiosk mode (no use of browser tabs there). But, inspired by your reload, I found another solution. Not so elegant to look at, because the dashboard just refreshes its complete browser. I'm using another integration of @thomasloven for this: browser_mod

I added this service call to the 'select theme' automations action:

      - service: browser_mod.window_reload
        data:
          deviceID:
            - browser_dashboard

@thomasloven
Copy link
Owner

Can you please check if this is still a problem in 3.4.0?

@tomlut
Copy link
Author

tomlut commented Dec 27, 2023

It is indeed fixed. Thank you Thomas. 👍

@tomlut tomlut closed this as completed Dec 27, 2023
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

3 participants