@Belgarion FYI @cosmicpuppy is @tgauchat (re-branding).
Here’s the code you can use to “share” the image with other SmartApps. Once you’ve extracted the raw jpeg byte stream from the httpGet or hubAction response you can use this to save the image to the ST cloud and send it to other apps to consume.
// Save the image to the S3 store to display
def saveImage(image) {
log.trace "Saving image to S3"
// Send the image to an App who wants to consume it via an event as a Base64 String
def bytes = image.buf
//log.debug "JPEG Data Size: ${bytes.size()}"
String str = bytes.encodeBase64()
sendEvent(name: "imageDataJpeg", value: str, displayed: false, isStateChange: true)
// Now save it to the S3 cloud, do this in the end since it removes the data from the object leaving it empty
storeImage(getPictureName(), image)
return null
}
private getPictureName() {
def pictureUuid = java.util.UUID.randomUUID().toString().replaceAll('-', '')
"image" + "_$pictureUuid" + ".jpg"
}
The SmartApps need only subscribe to the attribute imageDataJpeg
from your device handler (SmartTiles is testing this in BETA). The SmartApp can reverse the encoding from base64 back to byte using:
byte[] imageBytes = encoded.decodeBase64()