sibbl / hass-lovelace-kindle-screensaver

This tool generates a png from a Home Assistant Lovelace view, which can be displayed on a Kindle device which has the Online Screensaver plugin installed.
MIT License
333 stars 74 forks source link

Calendar Entries are not rendered #95

Open Texugooftomorrow2 opened 10 months ago

Texugooftomorrow2 commented 10 months ago

I've had sucess running the docker container, but any widget that involves calendar entries (calendar.xxxxxx) and/or some icons (like extended wheater forecast) don't get rendered at :5000, I've tried it with the native calendar card, atomic card, and lovelace home feed card, they show perfectly on the dashboard in kyosk mode, but vanish on the screenshot at :5000

sibbl commented 10 months ago

Please try setting RENDERING_DELAY to either 2500 or 5000 (2.5s or 5s). It let's the website settle after it's indicated that the website has been rendered for the given time. Sometimes Javascript code is executed with a short delay, which maybe too long for the Docker container. I hope it helps!

rgegriff commented 7 months ago

I ran into the same issue and set RENDERING_DELAY to 5000.

Watching the logs, It still seems to snapshot as soon as the page loads. It doesn't even load in all of the cards, let alone load the calendar data

beeh5 commented 6 months ago

@sibbl I have run into the same issue, curiously enough also with the Calendar widget. I have set my RENDERING_DELAY to a whopping 20000ms (20 seconds), but the Calendar widget still only shows the calendar entries about half of the time...

Not sure if the delay timeout actually works, but just from looking at the code, it looks okay. I was briefly considering that maybe the version of Pupeteer has become to old to work with current HA, but then again, my screen is shown correctly half of the time...

Any further ideas?

beeh5 commented 6 months ago

I ran the Docker Compose file on my local machine (M1 MacBook Air). Interestingly, once I set RENDERING_DELAY to a value higher than 0, I do not seem to get any calendar events in the screenshot at all. If I leave it at 0, the calendar events do get shown... Which is super weird, because you would expect that the additional timeout should give the program more time to render and not less...

That behaviour makes even less sense if you look at the code. From what I can tell, the only influence the rendering delay has is within the code statement below. How is this supposed to kill off the Calendar events from the view? I am really confused :D

    if (pageConfig.renderingDelay > 0) {
      await page.waitForTimeout(pageConfig.renderingDelay);
    }
beeh5 commented 6 months ago

@sibbl For testing purposes, I locally upgraded to a Node 18 image and the latest version of Puppeteer. It still shows that weird behaviour described before. (though they have removed the method page.waitForTimeout() in the meantime and require you to bring your own implementation).

What I noticed is that the calendar stuff indeed loads relatively late in the stage. And there are gaps of more than 500ms of network inactivity (thus networkidle0 is likely fired prematurely in many cases). Still, why would adding the timeout make things worse? Maybe HomeAssistant has some UI logic that is being interfered with by having the timeout? Visibility detection?

I keep digging some more.

beeh5 commented 4 months ago

@sibbl thanks for merging and releasing the fix so quickly. :-) At least for me, this has resolved the issue. I think you can close this issue for now.