I’m extending the Blink app and got struggle with the image recovery.
The Blink server gives a http error if the camera (http post for creating new snapshot) is busy. In this case I want to abort the image refresh in the Homey app and show a red message “camera is busy”.
I followed the Homey API description and trow an error. But the camera view is still busy with the circeling refresh icon and no message is shown.
The code is:
const _snapshotImage = new Homey.Image();
_snapshotImage.setStream(async stream => {
self.log('_registerSnapshotImage() -> setStream -> Capture_snap');
self._getNewSnapshotUrl()
.then(
//...get the immage via URL
res.body.pipe(stream);
})
.catch((error) => {
self.log("_registerSnapshotImage Error calling _getNewSnapshotUrl: "+error);
throw new Error('Camera is busy');
});
_snapshotImage.register()
.then(() => self.log('_registerSnapshotImage() -> registered'))
.then(() => self.setCameraImage('snapshot', 'Snapshot', _snapshotImage))
.catch(self.error);
I think it’s similar to the example below “Using a stream”:
https://apps-sdk-v2.developer.athom.com/tutorial-Images.html
Has anyone an example how to deal with errors on image refresh? Many thanks.
Ronny