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

Converting fails most of the time for no apparent reason #39

Closed noiob closed 2 years ago

noiob commented 2 years ago

98% of the time the convert command fails on my Pi 4 and I can't figure out why. This is a run where it worked once and then immediately failed again. I'm not sure if I even need the conversion since I just want a full color screenshot of my dashboard

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

Starting browser...
Visiting 'http://127.0.0.1:8123' to login...
Adding authentication entry to browser's local storage...
Starting first render...
Starting rendering cronjob...
Server is running at 5000
Rendering http://127.0.0.1:8123/lovelace/wall-display-test?kiosk to image...
Converting rendered screenshot of http://127.0.0.1:8123/lovelace/wall-display-test?kiosk to grayscale png...
Finished http://127.0.0.1:8123/lovelace/wall-display-test?kiosk
2022-05-19T15:16:48.727Z: Image 1 was accessed
Invalid request: /favicon.ico for page NaN
2022-05-19T15:16:54.726Z: Image 1 was accessed
Rendering http://127.0.0.1:8123/lovelace/wall-display-test?kiosk to image...
Failed to render TimeoutError: Navigation timeout of 30000 ms exceeded
    at /app/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111
Converting rendered screenshot of http://127.0.0.1:8123/lovelace/wall-display-test?kiosk to grayscale png...
/app/node_modules/gm/lib/command.js:301
          err = new Error('Command failed: ' + stderr);
                ^

Error: Command failed: convert: unable to open image '/output/cover.png.temp': No such file or directory @ error/blob.c/OpenBlob/3496.
convert: no decode delegate for this image format `TEMP' @ error/constitute.c/ReadImage/562.
convert: no images defined `/output/cover.png' @ error/convert.c/ConvertImageCommand/3273.

    at ChildProcess.onExit (/app/node_modules/gm/lib/command.js:301:17)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
  code: 1,
  signal: null
}

my envvars are

c
CRON_JOB=* * * * *
HA_ACCESS_TOKEN=[redacted]
HA_BASE_URL=http://127.0.0.1:8123
HA_SCREENSHOT_URL=/lovelace/wall-display-test?kiosk
LANGUAGE=de
NODE_VERSION=16.13.0
OUTPUT_PATH=/output/cover.png
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
RENDERING_SCREEN_HEIGHT=448
RENDERING_SCREEN_WIDTH=600
RENDERING_TIMEOUT=30000
ROTATION=0
SCALING=0.75
USE_IMAGE_MAGICK=true
YARN_VERSION=1.22.15
COLOR_MODE=TrueColor
RENDERING_DELAY=2000
sibbl commented 2 years ago

@noiob "Navigation timeout of 30000 ms exceeded" sounds like the RPi cannot render the page within 30sec. You can try increasing the RENDERING_TIMEOUT even more.

This unfortunately depends a lot on the hardware, the lovelace layout and what other stuff might be already running on your Pi.

The image conversation can currently not be disabled as it was built for eink devices. But might be worth adding this as an optional config parameter in the future. However, the image conversation is just a tony part of the whole process from navigating to the URL to getting a the final image.

noiob commented 2 years ago

hm, even bumping the timeout to 300s still has it fail sometimes. I would've thought chromium would run just fine on a Pi 4 (which doesn't run that much else) but I guess it doesn't. Maybe 2GBs of RAM isn't enough. Thank you for your reply!

andrazek commented 2 years ago

Hi. I have Pentium Silver N6000, 16GB of RAM, 1TB NVMe SSD, and often end up with exactly the same error.

noiob commented 2 years ago

@andrazek fwiw me poking around with my system ('s chromium ?) seems to have fixed it for me. It's running fine now