Skip to content
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

Use MQTT topic as an image source #685

Closed
hmorkemo opened this issue Mar 22, 2024 · 10 comments
Closed

Use MQTT topic as an image source #685

hmorkemo opened this issue Mar 22, 2024 · 10 comments
Labels
wontfix This will not be worked on

Comments

@hmorkemo
Copy link

Showing images in a panel is quite static, and the image files have to be locally stored.

I want to be able to send images from HA to the screen.

One solution to this is in PR #643, but it appears to have limitations due to memory usage and possible loss of OTA upgrades on older screens.
A better solution, I think, would be to have the image src parameter listen to an mqtt topic. (Ref #643, which is a good idea in itself).
Then I could say { id: "p2b10", obj: "img", ... , src: "mqtt:weatherforecast1" }

In HA I would then publish to mqtt { topic: "hasp/panel1/weatherforecast1", payload: theimage }.
The image format should be png or whatever OpenHASP can handle, encoded in a standard way.

@hmorkemo hmorkemo added the enhancement New feature or request label Mar 22, 2024
@pepe59
Copy link

pepe59 commented Mar 23, 2024

I don't have a better way. I am using sending a weather image using automation HA

service: openhasp.push_image
target:
  entity_id: openhasp.ovladac3
data:
  image: http://1xx.1x.x.xx:8123/local/pocasi/Blesky.png
  obj: p1b2
  width: 120
  height: 120
  fitscreen: true

@FreeBear-nc
Copy link
Contributor

In HA I would then publish to mqtt { topic: "hasp/panel1/weatherforecast1", payload: theimage }. The image format should be png or whatever OpenHASP can handle, encoded in a standard way.

Not sure you can have a binary file as a payload image with HA. The mqtt docs seem to suggest that payloads are converted to strings before being published.

@fvanroie
Copy link
Collaborator

fvanroie commented May 13, 2024

This is not something I'm keen on supporting, since the overhead of sending images over MQTT is substantial.
The MQTT receive buffer is a few kilobytes, so that would need to be increased to support this use-case, then more memory is needed to decode the image. For a resource limited device like the ESP32, I don't think the overhead and trouble is worth the benefit.

@dosipod
Copy link

dosipod commented May 13, 2024

@fvanroie I only started using openHASP recently because i got Sunton ESP32-2432S028 on offer , i really like what you did , amazing work . I was able to use bin images loaded internally but only few of them .

Being able to use external images i think would be a great addition, not really sure using HA is ideal ,what do you think the best was to do so even if we need to buy better devices but would also be nice that we could use what we have as the 4MB ESP32 is still very common and we have a ton of them and external display is very cheap .

@fvanroie
Copy link
Collaborator

fvanroie commented May 13, 2024

You can not defy hardware limitations in software: Dynamic images require RAM. The ESP32-2432S028 doesn't even have PSram.

Decoding JPEG or PNG require RAM and CPU resources, both of which are very limited on the ESP32. Hence the decoding from JPEG/PNG to BIN is done in Home Assistant as not to burden the ESP32 too much. Maybe it is not ideal for your use-case, but that doesn't mean openHASP should take over that processing job. Maybe you can implement an image proxy or something on a HTTP server if that fits your scenario better... Again, I don't think this necessarily needs to be done on the end device.

Unfortunately, a $4 ESP32 can't do the same tasks as a PC or a phone.

@fvanroie fvanroie added wontfix This will not be worked on and removed enhancement New feature or request labels May 13, 2024
@dosipod
Copy link

dosipod commented May 13, 2024

Thank you yes i think that makes sense and ESP32-2432S028 i got on offer was only $2 ,we will try to work on the image conversion if something could be done but I did also face somewhat the same issues with Tasmota and lvgl so i hope that will not be just a dead end

@fvanroie
Copy link
Collaborator

It depends on the size of the image and the free memory of the device... I guess you're going to need PSram for anything larger than 64x64 or so

@dosipod
Copy link

dosipod commented May 14, 2024

I looked into our stock and found few esp32 cam , will that do ?The aim is just to display images hosted on external server , nothing fancy and touch is not needed so any display is okay . Did not see that mentioned with openHASP

@smcgann99
Copy link

smcgann99 commented May 21, 2024

@fvanroie Sorry this is off topic but -
Hence the decoding from JPEG/PNG to BIN is done in Home Assistant as not to burden the ESP32 too much

I don't use HA, but I do use a http image source pointing to a png on my node red server. From the above would it be more efficient to convert to bin and host the BIN file ?

@fvanroie
Copy link
Collaborator

Yes indeed. PNG/JPEG can't be used directly in LVGL and have to be decoded to BIN first. This happens in memory on the ESP32.
You can save memory and CPU cycles when the decoding is done externally, at the expense of a little bit more network traffic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants