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
311 stars 71 forks source link

Failed to render TimeoutError: waiting for selector `home-assistant` failed: timeout 8986ms exceeded #28

Closed davyike closed 2 years ago

davyike commented 2 years ago

Hoping you can help me here. I've set up the docker container:

docker create --name="ha-kindle-screensaver" -p 5050:5000 -e HA_BASE_URL="https://<MYURL>" -e HA_SCREENSHOT_URL="/lovelace/climate?kiosk" -e HA_ACCESS_TOKEN="<ACCESSTOKEN>" --restart=always sibbl/hass-lovelace-kindle-screensaver

I get the following in the logs:

> hass-lovelace-kindle-screensaver@1.0.4 start
> node index.js

Starting browser...
Visiting 'https://<MYURL>' to login...
Adding authentication entry to browser's local storage...
Starting first render...
Starting rendering cronjob...
Server is running at 5000
Rendering https://<MYURL>/lovelace/climate?kiosk to image...
Failed to render TimeoutError: waiting for selector `home-assistant` failed: timeout 8986ms 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:257:16)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async renderAndConvertAsync (/app/index.js:171:5)
Converting rendered screenshot of https://<MYURL>/lovelace/climate?kiosk to grayscale png...
/app/node_modules/gm/lib/command.js:301
          err = new Error('Command failed: ' + stderr);

Unsurprisingly, I get "Image not found" when hitting the server. Any tips? It looks like it's authenticating OK, right?

davyike commented 2 years ago

Hmm, just noticed I have this in my HA logs though:

Login attempt or request with invalid authentication from 172.17.0.22 (172.17.0.22). (Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/81.0.4044.113 Safari/537.36)

Maybe it's the auth playing up after all. Deleting the access token from HA seems to have no impact on the logs, so perhaps this is not being detected correctly.

davyike commented 2 years ago

Got it! I'd missed part of the Access Token. 🤦🦆

Is there a way to better catch/show this in the logs?