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 CSS values not consistently rendering #85

Open
gdst4rp opened this issue Oct 11, 2023 · 16 comments
Open

card_mod CSS values not consistently rendering #85

gdst4rp opened this issue Oct 11, 2023 · 16 comments

Comments

@gdst4rp
Copy link

gdst4rp commented Oct 11, 2023

My dashboard uses code like the following, but the output rendered image will randomly vary from using the CSS elements (bold, font size, and borders), or completely ignoring them. If I view the dashboard from my browser, everything works just fine. Checking the native image itself, I see that the render is also not consistent which rules out the Kindle device. I have tried different rendering_delay values as well

I'm guessing it's something to do with how the page is rendered.

card_mod:
style: |
ha-card {
border: 2px solid black;
font-weight: bold;
}
.forecast {
font-size: 20px;
}

@gdst4rp
Copy link
Author

gdst4rp commented Oct 11, 2023

For what it's worth, even using this yaml instead doesn't product consistent results (without using card_mod specifically):

style: |
ha-card {
border: 2px solid #000000;
font-weight: bold;
width: 600px;
font-size: 20px;
}

Here are two examples of different renders. Nothing has changed between them, I just waited a bit and refreshed my homeassistant:5000 image pull from my web browser. The kindle reflects this image exactly. The image with the bold lines/text is what it should look like based on my style. Without the bolds, it's harder to read the text on the Kindle.

homeassistant2
homeassistant

@gdst4rp
Copy link
Author

gdst4rp commented Nov 15, 2023

Any chance someone can take a look and let me know if I'm doing something wrong?

@sibbl
Copy link
Owner

sibbl commented Nov 15, 2023

I can recommend setting RENDERING_DELAY to some value like 2500 or 5000 (2.5 / 5 seconds). It's the time the browser let's the website apply changes like CSS or JS to the website before taking the screenshot. It can help letting Home Assistant settle the rendering process.

@gdst4rp
Copy link
Author

gdst4rp commented Nov 15, 2023

I did try that unfortunately with varying levels of delay. The screenshots above came after using a setting of 20000, which I believe should be 20 seconds. I started much smaller, then kept moving up.

Sometimes, only part of the screenshot is wrong (e.g. the forecast section will be bold, but the other ones won't be. It's a real head scratcher for me.

@ja-m
Copy link

ja-m commented Mar 24, 2024

I have the same issue as gdst4rp.
I use card_mod to modify the cards for the screenshot. Sometimes the card_mod changes are not included in the render screenshot.

@gsmckenzie
Copy link

Same here. I have tried delays up to 60 seconds. Works really inconsitently. I am wondering if Puppeteer is having issues with card-mod. Frustrating things that it works some of the time. I even tried access the Puppeteer instance and changing the user agent, but that didn't improve results.

@gsmckenzie
Copy link

I suspect it is a caching issue inside docker. In general the first run works and then it is inconsisent.

@sibbl
Copy link
Owner

sibbl commented Mar 27, 2024

Just a quick question before I will debug this further: did you all install lovelace-card-mod via extra_module_url in the configuration.yaml or differently? There seem to be multiple ways, according to their docs.

@ja-m
Copy link

ja-m commented Mar 27, 2024

I use the performance improvement via extra_module_url.

frontend:
  extra_module_url:
    - /homeassistant/www/community/lovelace-card-mod/card-mod.js

@gsmckenzie
Copy link

gsmckenzie commented Mar 27, 2024

I use the performance improvement via extra_module_url.

Same I think off the top of my head but can confirm later.

frontend:
extra_module_url:
- /local/card-mod.js
themes: !include themes.yaml

@ja-m
Copy link

ja-m commented Mar 28, 2024

It seems there are problems in card_mod:
thomasloven/lovelace-card-mod#359
thomasloven/lovelace-card-mod#354

@gsmckenzie
Copy link

I have tried very simple cards, with a single weather element and a delay of 50 seconds and I still get inconsistency.

The page will render in Chromium Canary on my macbook in under a second. I think get a correct render of the page 1 in 20 times (but not properly tested), but I can do if it is helpful?

@cln-io
Copy link

cln-io commented Jul 26, 2024

Did any of you figure this out? 👀

@avhm
Copy link
Contributor

avhm commented Aug 6, 2024

this fixed this issue for me: If you've installed card-mod via HACS, try adding the module directly to the frontend in your configuration.yml:

frontend:
  extra_module_url:
    - /hacsfiles/lovelace-card-mod/card-mod.js

@gsmckenzie
Copy link

@avhm That looks like it works for me. Thanks for chasing this down.

@ja-m
Copy link

ja-m commented Aug 8, 2024

@avhm I changed the path to card-mod.js like you suggested. Now it works for me, too.

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

6 participants