I am doing something wrong, but I can’t seem to find enough information in the SDK documentation to get it right.
I have a device and I need it to display an image. I found the setCameraImage function to be the only possibility (besides album art, but that gives me a load of uiComponents I don’t want/need)
In the driver.js I have an updateEvent that produces a new image. After I download the image I use this to make the image viewable as a camera image:
const myImage = await this.homey.images.createImage();
this.setCameraImage('Blabla', object.date , myImage );
object.date represents the date/time the image was created. All seems to work well, but for every new image I get a new camera ?!?!?!?
Apperantly I’m not getting how this should work
Any hints on how to do this the right way? I guess I need to do the createImage() and setCameraImage() outside of the updateEvent (and do them only once?) but how do I then update the CameraImage when a new image is downloaded?
And, is there a way to change the title of the image that way? Or should I better be using the Album Art, but then I hope there a way to hide the media buttons (prev/next & play/pause)?
I’m doing it that way:
const mapImage = await this.homey.images.createImage();
this.setCameraImage('warnmap', this.homey.__('warnmap.titleState'), mapImage);
const mapImageGermany = await this.homey.images.createImage();
this.setCameraImage('warnmapGermany', this.homey.__('warnmap.titleCountry'), mapImageGermany);
This way I register two camera images (with url instead of path) for a device.
First parameter is the image id, second the caption, thirth the image itself.
So if you keep the id unchanged, it should update the image. But I use a conctant caption. Perhaps your dynamic caption (date/time) is causing the GUI issue. In that case I would use a consant i18n caption for the image and a sensor for the date/time information.
Thanks, that is what I have now, except I guess because I repeatedly do a createImage I get multiple camara’s.
What do you do to update the camera when a new image arrives? Just run a mapImage .update() command?
If I remember right, I don’t update from inside the app. If the user calls the view (camera tab in your device), the device is reading the set url/path and displays the image.
In my case it’s a URL to a generated weathermap from a weather provider.
In your case it’s a image file. So if you just update the image in background (and keep the file name), the device will load the given image file (I think).
Excellent! I will try that. Thanks for your help!