Hi folks.
I’m working on a custom notify component to show images and messages on a Divoom Timebox display. I’ve got the basic connection stuff and am able to tell the device to switch display modes (sending a notification to switch between the built-in clock and temperature displays). Next step is to be able to send custom images and animations.
In python code, an image is an 11x11 2D array of pixels, each pixel consists of an array of three ints in the range 0-15. For example, my component shows a home assistant logo when it connects, the python code for that is
bp = [3, 3, 14]
wp = [15, 15, 15]
logo = TimeBoxImage()
logo.image = [[bp,bp,bp,bp,bp,bp,bp,bp,bp,bp,bp],
[bp,bp,bp,bp,bp,wp,bp,bp,bp,bp,bp],
[bp,bp,bp,bp,wp,wp,wp,bp,wp,bp,bp],
[bp,bp,bp,wp,wp,wp,wp,wp,wp,bp,bp],
[bp,bp,wp,wp,wp,bp,wp,wp,wp,bp,bp],
[bp,wp,wp,bp,wp,bp,wp,bp,wp,wp,bp],
[bp,bp,wp,bp,wp,bp,wp,bp,wp,bp,bp],
[bp,bp,wp,wp,bp,bp,bp,wp,wp,bp,bp],
[bp,bp,wp,wp,wp,bp,wp,wp,wp,bp,bp],
[bp,bp,wp,wp,wp,bp,wp,wp,wp,bp,bp],
[bp,bp,bp,bp,bp,bp,bp,bp,bp,bp,bp]]
And an animation would simply be an array of images, with an optional frame delay.
My question is, how should I best send this information? I’m considering converting these arrays to JSON and just stuffing it inline in the data
attribute of a service call. My concern there, though, is that even though a payload like this would likely max out at a few kilobytes, it’s still much larger than anything I’ve seen the HA event bus used for before. Would passing payloads this large around have performance impacts?
The only other option I can think of is writing image data to files in a temp directory and passing references to that around. Is there a specific mechanism for creating temp files in HA that would be suitable for this?
Finally, is using the notify platform even the best place to provide a service like this? I picked it because it seemed logical to me as a component that messages and images are written to. But happy to take suggestions for alternatives.