Seeking a bit of guidance: Local JPEG file utilized by Meural Canvas II device driver

I am seeking a bit of guidance please.

I have written a Meural Canvas II device driver.

At present it can suspend the Meural canvas, wake it from sleep mode and I have access to the light sensor that is built-in to the Canvas. I intend to continue development to give control over the picture galleries, etc.

Meurals have the ability to load pictures directly from a local device. I would like to improve my driver to facilitate the display of pictures stored locally on the Hubitat. I imagine use cases that would temporarily change the Meural display in response to some sort of event.

I have isolated the Javascript that performs this action on the Meural.

On line 28 you can see the append to FormData. BTW - I am by no means a JS programmer.

I have tried to duplicate the same functionality in Groovy. My first attempts were unsuccessful due to the FileWriter being blocked in Hubitat. Ref: Importing [] is not allowed

I then found code written by @thebearmay (thank you!) that I found promising and I attempted to adapt it for a binary load. See lines 311 & 320 below:

I adjusted my usual post request code as follows:

Note that in line 146 I am attempting to match the format of the original JS append.

Unfortunately, my post request fails:

So with my level of expertise in diagnosing the failure I am unsure of the cause. I suspect that my data object or perhaps its presentation in Groovy is the cause of the failure.

So in summary, I am seeking assistance with replicating and adjusting the functionality of the original JS so that I might post a JPEG image stored locally on the Hubitat to a Meural Canvas.

Many thanks in advance - Norbert

Writing a blob file (images, etc) to the file manager from an app/driver has been, shall we say, problematic.


The Meural Canvas supports hosting images locally from an SD card doesn't it? Would it be possible to call it up from there? **Not a programmer, I have no idea what I'm talking about

1 Like

Thank you for the suggestion!

Absolutely true and yes it certainly would work for the use case that I mentioned. As a matter of fact we use SD cards for our two Meurals. The primary reason is that the only available internet provider in our area offer very slow upload speeds so loading photos to the Meural hosted website is untenable.

Unfortunately the SD card option doesn't allow for changing pictures "on-the-fly". I had hoped that it would be possible and I even programmed a Toshiba WiFi SD card for that purpose. Unfortunately the Meurals seem to want a reboot to recognize the new pictures.

Long story short, I am really driving at a methodology that will enable flexible picture changes without rebooting or physically interacting with the Meural. Eventually I hope to also build an interface to automatically load Google Photo albums.

Do you re-size you images before uploading to the Meural Canvas cloud storage? Seeing as the screens are 1920x1080 I resize everything first, 80% of my images are less than 500kb.

I also shoot a lot in 4:3 so I've come up with a fairly quick and dirty way to add blurred edges in Affinity Photo that I prefer over white/black bars.

It still boggles my mind that for this kind of $$$ the screens aren't in 3:2

Thanks to @Younes I've now cracked this nut...