# setCameraImage

**URL:** <https://community.homey.app/t/setcameraimage/74369>\
**Category:** Developers\
**Created:** [December 30, 2022, 7:50pm UTC](https://community.homey.app/t/setcameraimage/74369 "2022-12-30T19:50:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [December 30, 2022, 7:50pm UTC](https://community.homey.app/t/setcameraimage/74369/1 "2022-12-30T19:50:45Z")

</div>

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:

```auto
	const myImage = await this.homey.images.createImage();
	myImage.setPath("/userdata/image.png");
	myImage.update()
	this.setCameraImage('Blabla', object[0].date , myImage );

```

object[0].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)?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 31, 2022, 8:58am UTC](https://community.homey.app/t/setcameraimage/74369/2 "2022-12-31T08:58:17Z")

</div>

I’m doing it that way:

```auto
      const mapImage = await this.homey.images.createImage();
      mapImage.setUrl(imageUrl);
      this.setCameraImage('warnmap', this.homey.__('warnmap.titleState'), mapImage);
      const mapImageGermany = await this.homey.images.createImage();
      mapImageGermany.setUrl(countryUrl);
      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.

 ![grafik](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/b/5b50623f3b016c7bacb25e8546454b1c4d36aa37.png)

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [December 31, 2022, 3:04pm UTC](https://community.homey.app/t/setcameraimage/74369/3 "2022-12-31T15:04:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 31, 2022, 3:10pm UTC](https://community.homey.app/t/setcameraimage/74369/4 "2022-12-31T15:10:14Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [December 31, 2022, 3:25pm UTC](https://community.homey.app/t/setcameraimage/74369/5 "2022-12-31T15:25:14Z")

</div>

Excellent! I will try that. Thanks for your help!
