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

HomeAssistant Add-on setting the output path #86

Open alfwro13 opened 11 months ago

alfwro13 commented 11 months ago

Hi, I have this installed as Home Assistant Addon, I have it running but I cannot figure out how to set the path correctly. I added: OUTPUT_PATH: /media/output.png to the config thinking that this will save it to the home assistant media folder but it give me error message:

[Error: ENOENT: no such file or directory, open 'output/cover.png'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'output/cover.png'
}

if I remove the OUTPUT_PATH line I still get the same error message. What am I doing wrong?

sibbl commented 11 months ago

Hi @alfwro13

the OUTPUT_PATH refers to the file system inside the docker container. It's sandboxed and thus separated from the home assistant file system, where the media folder is located.

From a Docker perspective, you could theoretically mount a folder from the HA file system into the addon system, but the HA addon might need further configurations to allow this. By default, the security principles of HA addons don't allow this.

Maybe I can help you more if you could give some insights into what you want to achieve in general?

alfwro13 commented 11 months ago

What I want to do is use this to addon to save a lovelace card and then display the saved card on an ESPHome display using this: https://github.com/esphome/esphome/pull/4710

I am not using docker I am running the Home Assistant Add-on version and even without the OUTPUT_PATH I still get the no such file or directory error message?

sibbl commented 11 months ago

As far as I understand the linked PR, it should work without using the file system or mounting the OUTPUT_PATH as long as the ESPHome can reach the HA Addon via HTTP or HTTPS.

The "OUTPUT_PATH" is just some internal thing and not meant to be used - except for debugging and manually checking the file for example. See it as some internal temp variable, which would allow you to say "please save the temporary file somewhere else on the file system".

In the end, the whole project offers an HTTP endpoint which will deliver this image. Just find out your addon's URL and append the /1 or /2 path to get the 1st or 2nd config image (or not path at all to get the 1st config image as the default one). This HTTP endpoint will deliver the image (which internally is stored at the location stored in the OUTPUT_PATH variable).

So by pointing ESPHome to that URL, it should directly fetch the image from the addon and should be ready to go. I don't see any need to put the image on the file system of HA first and then delivery it to ESPHome again somehow, when there's a direct possibility.

fpetry commented 1 week ago

I'm trying to access the HTTP endpoint from an Inkplate 6, which is not working. Browsers show the image under http://:5000/ fine, but the drawImage() method of the Inkplate library 1 cannot parse the output. However, they write:

Can draw all kinds of images, but they should have a file extensions in them.

Hence, I tried to change the OUTPUT_PATH, but it doesn't change the URL where the image is being served. It would be nice to have the image available at http://<HASS-IP>:5000/output.png or http://<HASS-IP>:5000/output.jpeg.

UPDATE: There are people with the same problem 2, working around it with a webserver which adds the file endings... Would be nice to have this in here directly.