Hypfer / ICantBelieveItsNotValetudo

A Valetudo companion service which renders maps to pngs
Apache License 2.0
129 stars 80 forks source link

Endpoint for base64-encoding #66

Closed ingoschi closed 2 years ago

ingoschi commented 2 years ago

I'm convinced (it's kind of my white whale) that the "View the map"-workaround described at openHAB integration doesn't work because the MapURL Image Item can't be updated with the ICantBelieveItsNotValetudo image url but with the image as base64-encoded string.

So my solution was to add a webserver endpoint api/map/base64 (I don't publish the base64-encoding to MQTT, but this could be also added)

I only found old code that handled base64 for getting the map data from Valetudo but not for delivering it with ICantBelieveItsNotValetudo.

I thought the most efficient way to get the encoding was to use directly the canvas with which the MapDrawer draws the image. But therefore I had to change MapDrawer.draw() to return the image and the string.

I'm not aware of the costs of toDataURL(). Maybe this functionality should be made optional by config.json.