-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add runtime online image support #4710
base: dev
Are you sure you want to change the base?
Conversation
Hey there @guillempages, CODEOWNERS = ["@guillempages"] And run (message by NeedsCodeownersLabel) |
2d9ac93
to
29137f1
Compare
29137f1
to
8cdba86
Compare
If I understand correct, the image is only downloaded when updated? I have a dynamic image, which I which to download and display every minute or less. I suppose I now need to update then display ? Feature suggestion: Event on update/download finished, e.g. for a call to display the image once downloaded. |
@osos yes, the image needs to be updated and then the display as well.
than
Of course, I forgot about the "update_interval" case :-( That would be a "valid" use case for the
and would achieve the same. |
8cdba86
to
827a618
Compare
a8f6a4f
to
90d18c0
Compare
I am unable to get esphome to build using the components in this PR (I was against PR #3255). This is the relevant config part:
Which fails with
I have tried different things to get it to compile, but in the end I have realised that just changing the PR number to 3255 works and 4710 does not. Any idea of what might the problem be? |
Found the issue: missing dependencies and esphome silently eating the exception. Missing dependencies in the official docker container are |
@DominoLeChat Sorry, I have no idea what could possibly be wrong with that combination :-( I don't have a waveshare that I could try on. One thing that comes to mind, if I am reading your configuration right, your screen is a 3-color (white, black, red) one, right? Do you know how the pixels are being drawn to that screen? Or which format do images use to draw? It might be a mismatch between what the custom component driver expects as a color format, and what the online_image supports. You might want to try (just to see if this helps) other pixel formats ( |
Hello - I am running into the following error when trying to install. external_components:
- source: github://pr#4710
components: [ "online_image" ]
|
@ianByrne sorry about that error. I did a fix for the beta, and somehow forgot, that the release is not yet out 🫤. When the next release is released (should be on Wednesday if I am not mistaken) the issue will be automatically fixed. Meanwhile I'll try to do some hack tomorrow, to see if I can make it work again on the previous versions as well. |
Hi! This still doesn't work for me although my esphome is on 2024.5.4
and these are the errors I get when compiling:
|
Add the possibility of freeing the memory used by an online image
- Add follow_redirects option Allow enabling/disabling HTTP follow redirect option. Automatically end the download loop when the image has been fully downloaded. - Add ETag support Avoid re-downloading an image, if the server says that the image hasn't changed. Also add an action to release the used buffer. - Allow setting UserAgent - Allow setting HTTP timeout value Force esp8266 >= 2.7.0 or esp32 framework
Add callbacks that will be called when an image is successfully downloaded or an error happened during download.
1b92b13
to
9b29bb6
Compare
@DohmenICT Your problem is a different one. You are using an ESP8266, and I have actually never tested the code there. So it does not even compile 😕 I have updated the code now to support (at least compiling) on ESP8266, but I am not really sure that it will work as you expect; probably you will run into issues because of low performance or low memory. Please, do test it with the latest version, and let me know whether it works at all. |
68e9470
to
093648b
Compare
Hi, thanks for your feedback. The code compiles now and I can upload it. But I get a weird error where the complete url of the image isn't shown in the logging:
This is my code:
|
093648b
to
5d83b71
Compare
saw the new commit; testing.... |
Still something wrong with the url in the logging...
|
# Online Image specific options | ||
# | ||
cv.Optional(CONF_FORMAT, default="PNG"): cv.enum(IMAGE_FORMAT, upper=True), | ||
cv.Optional(CONF_BUFFER_SIZE, default=2048): cv.int_range(256, 65536), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My screen is a 13.3 inch eink, which are 960x680 which is 81600 bytes. :(
can we increase this to 98304 maybe ?
PR for adding the support for 13.3inch screen size to esphome: #6443
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to increase that? This is not the buffer to hold the decoded image; this is the temporary buffer that is used to download the image chunks before decoding.
The image is downloaded in chunks of this size and decoded on the fly.
Do you have an actual problem with using the default size of the buffer? This option was actually added at some point to debug an issue someone else was having, but it is not intended to be used except in some very special cases, where the chunk downloading does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might have tried to increase the buffer size to get past the error i got, but that might just have been me not having enough free Heap Size for storing and resizing the image. Let me resolve this, there is not resolve button on this repo.
[17:28:10][D][main:456]: downloaded image
[17:28:10][W][component:237]: Component esphome.coroutine took a long time for an operation (107 ms).
[17:28:10][W][component:238]: Components should block for at most 30 ms.
[17:28:10][D][online_image:175]: Allocating new buffer of 81600 Bytes...
[17:28:10][E][online_image:190]: allocation failed. Biggest block in heap: 48116 Bytes
[17:28:10][E][online_image.png:061]: Error decoding image: No IHDR chunk is found
[17:28:10][E][online_image:225]: Error when decoding image.
[17:28:10][D][main:449]: Error downloading image
[17:28:12][D][sensor:094]: 'Heap Free': Sending state 145268.00000 B with 0 decimals of accuracy
[17:28:12][D][sensor:094]: 'Heap Max Block': Sending state 98292.00000 B with 0 decimals of accuracy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "there is no resolve button"? Do you mean that this conversation should be resolved and you don't see the button? I see it, but maybe because I am the owner of the PR ;-)
Or do you mean that the issue is not resolved? Your log looks strange; the biggest reported block is different for the online_image and for the debug sensor, but I actually copied the max block reading code from the debug sensor 🤔
Does your device have PSRAM and if so, is it enabled and working? Images do need a lot of memory, so PSRAM is almost mandatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "there is no resolve button"? Do you mean that this conversation should be resolved and you don't see the button? I see it, but maybe because I am the owner of the PR ;-)
yeah, its just my view and this thread I started should probably be resolved, as it might not be an issue with your code.
Or do you mean that the issue is not resolved? Your log looks strange; the biggest reported block is different for the online_image and for the debug sensor, but I actually copied the max block reading code from the debug sensor 🤔
This might be a product of the debug code running every X seconds, and thereby not reading the memory at the time of running the pngle_feed
function. So don't read too much into it.
esphome/esphome/components/online_image/png_image.cpp
Lines 59 to 61 in d5cec7d
auto fed = pngle_feed(pngle, buffer, size); | |
if (fed < 0) { | |
ESP_LOGE(TAG, "Error decoding image: %s", pngle_error(pngle)); |
Does your device have PSRAM and if so, is it enabled and working? Images do need a lot of memory, so PSRAM is almost mandatory.
I don't have one with PSRAM that i can get to work right now.
and thanks for all the work on this PR!
but you can resolve this thread, as I won't be able to debug any more for the time being.
ESP8266 was not compilint. Fixed it and added a test for it.
5d83b71
to
d5cec7d
Compare
Oops, my bad. Should be fixed now. And I've changed the error code to a string as well, to make it better understandable. |
Well! The URL now shows in the error message.... But the error message doesn't :-D [19:53:52][I][app:100]: ESPHome version 2024.5.5 compiled on Jun 11 2024, 19:52:40 |
What does this implement/fix?
This PR implements the possibility of downloading PNG images at runtime and showing them in a compatible display.
Types of changes
Related issue or feature (if applicable): fixes esphome/feature-requests#1463
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#2076
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: