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

hass-addon does not render png #68

Closed Pattern91 closed 1 year ago

Pattern91 commented 1 year ago

Hey,

first of all big thanks for converting your project to a hass-addon!

The Plugin tells me that the render-timout is exceeded and stops. Can anyone point me in the right direction? The URL is correct and does work when i open it in a normal browser.

`s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service legacy-services: starting s6-rc: info: service legacy-services successfully started [15:40:39] INFO: Starting npm server... [15:40:45] INFO: Using base_url: http://192.168.178.12:8123

hass-lovelace-kindle-screensaver@1.0.4 start node index.js Starting browser... Visiting 'http://192.168.178.12:8123' to login... Adding authentication entry to browser's local storage... Starting first render... Starting rendering cronjob... Server is running at 5000 Rendering http://192.168.178.12:8123/lovelace-eink/home?kiosk to image... Failed to render TimeoutError: Navigation timeout of 50000 ms exceeded at /app/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111 Converting rendered screenshot of http://192.168.178.12:8123/lovelace-eink/home?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/3569. convert: no decode delegate for this image format TEMP' @ error/constitute.c/ReadImage/746. convert: no images definedoutput/cover.png' @ error/convert.c/ConvertImageCommand/3342. at ChildProcess.onExit (/app/node_modules/gm/lib/command.js:301:17) at ChildProcess.emit (node:events:513:28) at maybeClose (node:internal/child_process:1091:16) at Socket. (node:internal/child_process:449:11) at Socket.emit (node:events:513:28) at Pipe. (node:net:322:12) { code: 1, signal: null } Node.js v18.16.0 s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped`

sibbl commented 1 year ago

Hi @Pattern91,

thanks for your kind words!

Failed to render TimeoutError: Navigation timeout of 50000 ms exceeded

It seems that the machine is not able to open the page and finish rendering it within 50s. The value is already quite high, so it could be possible that your machine is too slow for running this project.

You can try to increase the RENDERING_TIMEOUT to something above 60000 milliseconds (maybe try it in 10s steps). Please also adapt CRON_JOB accordingly, as it will try to render a new image every minute - which might fail if the rendering takes longer than 1 min. The cron job value */2 * * * * will trigger the rendering of a new image every 2 min instead of 1 min.

I hope you can get it running! I'll keep in mind to make this a bit more easy to a) figure out and b) configure the values in the Hass.io addon.

Pattern91 commented 1 year ago

Hi @sibbl ,

thanks for you fast reply. I already have the cron job value so that in only runs every 10 minutes. I just want to move my installation from the docker container to the ha-addon. In the container the rendering was about 2-5 seconds.

The system is running on a RPi 3b+

sibbl commented 1 year ago

Just for my understanding: the docker container was also running on the same device before, or do you want to move it from another system?

Pattern91 commented 1 year ago

yes, the docker container was running on the same device using portainer. I stopped the container and installed the ha-addon instead and copied the values from the old configuration.

sibbl commented 1 year ago

Very strange, indeed. Unfortunately I'm not that familiar with the Hassio addon development details, so I don't know what's technically different to running the container without the addon base image.

The only thing I could think of is that the IP might not be accessable from the docker instance due to security constraints of the HA addon sandbox - we don't request the permission to run in the host network. Even though the IP leads to the same device, the docker network is a bit different and probably the request ends up being sent to your router, which sends it back to the device. But the addon doesn't know that...

Do you have a public domain set up, which you could try instead of the local IP and give it another try?

Pattern91 commented 1 year ago

unfortunately i don't have a public domain. Is there another way instead of using the local ip-address of the pi?

i can access the used lovelace dashboard from other devices in my network.

814d3 commented 1 year ago

Maybe this compose file helps, as I also use docker on a Pi 3b:

services: kindle_screen: image: sibbl/hass-lovelace-kindle-screensaver:latest container_name: kindle_s restart: unless-stopped environment:

sibbl commented 1 year ago

@814d3 thanks for the file. You also have troubles or do you say it's working for you and just wanted to provide a working docker compose file? Because if I understood the issue above correctly, the docker compose way is also working fine - but that there are problems when moving to the Hass.io solution on the exactly same device. Which obviously should work as the resources were there before.

814d3 commented 1 year ago

I see. Sorry, then I misunderstood it. That docker compose file is working for me, but I don't use it as/for a hass plugin. For me it looks like a IP or Port problem aswell. Good luck.

Pattern91 commented 1 year ago

@sibbl Did you change anything in your new version 1.0.5? It is somehow working after the update! Big thanks"

sibbl commented 1 year ago

The best issues are those which resolve themselves 😁

Thanks for the feedback. Only the battery webhook environment variable was added, but maybe also a new hassio base image was used when building - which might include bug fixes I don't know about.

Feel free to continue this thread if you encounter the issue in the future again!