I am trying to consume base64 encoded jpeg sent through mqtt.
However it seems that mqtt binding / Generic MQTT Thing with its image channel cannot resolve what the encoded image really is - it expects binary data, not base64 encoded.
I was trying to use “Incoming Value Transformations” of the image channel but it does nothing, like it was not used param in the channel at all.
How can I consume base64 encoded jpg from mqtt to have a valid image item?
How does your transformation look like ?
Did you try something like How to set the image content of an image item ?
For more clafirication:
I have two sources of images through mqtt.
First source is iotlink which sends raw binary of the screenshot. And following WORKS:
Second source is BlueIris which sends jpeg encoded with Base64. This is not binary, but encoded on the mqtt level already. This is not recognized by a Mqtt image channel as a valid jpeg but rather as binary octet stream:
I have added a transformation (ATOB.js):
With code of ATOB.js:
but it seems that MQTT binding does not use “Incoming Value Transformations” channel config field for image type at all (I have checked it against invalid js file to confirm that).
How can I solve the problem in most elegant way with the second source?
That is possible.
Can you get a stringy raw version, using a string type channel?
Note that a transformation must return a string, too.
Yeah! It worked flawlessly!
- Created MQTT channel with type Text.
- Added image item.
- On the channel added transformation like
return 'data:image/jpeg;base64,'+ i;
And the effect:
I’m surprised, I was thinking diagnostic step, but that’ll do
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.