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

Crash waiting for selector #53

Closed meetfinger closed 1 year ago

meetfinger commented 1 year ago

I get this error every start of the container after a few tries to render. It wont render an image, possibly because of different declared selectors? My home-assistant is the latest stable and running in a separate container. I played a bit with the render-timout but eventuelly the error comes up every time.

Failed to render TimeoutError: waiting for selector `home-assistant` failed: timeout 22712ms exceeded
    at new WaitTask (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:517:34)
    at DOMWorld.waitForSelectorInPage (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:428:26)
    at Object.internalHandler.waitFor (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77)
    at DOMWorld.waitForSelector (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:321:29)
    at Frame.waitForSelector (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:924:51)
    at Page.waitForSelector (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2359:33)
    at renderUrlToImageAsync (/app/index.js:260:16)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async renderAndConvertAsync (/app/index.js:173:5)
sibbl commented 1 year ago

Which was the highest rendering timeout you've chosen? DId you increase it to 50000 (=50s) or even higher?

What the error basically say: the internal browser is navigating to the URL and then it waits for the HTML element home-assistant which basically is the main container element of the HA dashboard. It fails to find this after the mentioned timeout of 22.7s according to your log.

This may have different causes. Either the rendering instance is too slow, the home assistant instance is too slow or there's something on the dashboard, which takes very long to load. If it is only occasionally taking long, I'd guess it's one of the first 2 possibilities.

meetfinger commented 1 year ago

Hi, thanks for quick reply!

Increasing the timeout, even to 100000, just delays the error. I get it everytime. The HA-Dashboard is just a single sensor status (window open/close) and loads qickly. Also i can find a html piece in the html-code: ... <home-assistant></home-assistant> ... I have to miss something really obviuous. Is the kiosk-mode mandatory?

meetfinger commented 1 year ago

I got it working after several hours! My authentification token was a few characters too short. I may have missed some in the copy-paste process. I only realized it because i got a notification of a failed login-attempt in the browser-tab of HA. Now i gotta get that image to my old kindle...

sibbl commented 1 year ago

No, the kiosk mode is optional. Maybe you can check your HA_SCREENSHOT_URL again? Is it starting with a slash? The HA_BASE_URL seems not to be a problem since the login seems to have succeeded already, but perhaps you can check it again as well.