For use in an external application (HomeHabit) I need to provide an image. This image is stored in openhab as an image item provided by the HEOS binding. But the application is requesting a string containing the image URL.
Is there any way to create such a string item in openhab out of the existing image item?
Not easily. The state of the Image Item is base-64 encoded so you can’t just provide the URL using the REST API to get the state of the Item. What you’ll have to do is write the state of the Item to $OH_CONF/html and convert the base-64 encoding back to the binary image format. Then HomeHabit can use http:<OH ip or hostname>:8080/static/<nameOfFile>.png.
Thanks for your response. I tried it out and created a rule:
rule "Get image URL"
Item Denon_AVRS660H_Cover changed
val file = "/etc/openhab/html/CoverHEOS.jpeg"
// Download it using wget
executeCommandLine("wget -O "+file+" "+Denon_AVRS660H_Cover.state.toString)
but when executing I get an error message:
va.io.IOException: Cannot run program “wget -O /etc/openhab/html/CoverHEOS.jpeg raw type (image/jpeg): 42640 bytes”: error=2, No such file or directory
Check the executeCommandLine docs … Arguments need to be separated by comma from the command. executeCommandLine interprets the complete strings as a command while just wget is the command and remaining part are arguments.
I have the impression that the part behind the file name does not look like an URL.