Images

A Device can have one or more references to a registered Image.

Album Art

A device can have one album art image attached. Register the images once, and then keep updating it.

/drivers/<driver_id>/device.js

const Homey = require('homey');

class MyDevice extends Homey.Device {
  async onInit() {
    this.image = await this.homey.images.createImage();
    this.image.setUrl(null);
    await this.setAlbumArtImage(this.image);

    this.myDeviceApi.on('track', track => {
      const albumArtUrl = track.albumArtUrl; // e.g. https://www.example.com/track/abcd/image.png
      this.image.setUrl(albumArtUrl);
      this.image.update().catch(this.error);
    });
  }
}

Camera

A device can have one or more camera images.

const Homey = require('homey');

class MyCameraDevice extends Homey.Device {
  async onInit() {
    this.image = await this.homey.images.createImage();
    this.image.setStream(async (stream) => {
      const res = await fetch(this.myDeviceApi.localImageUrl);
      if (!res.ok) throw new Error(res.statusText);
      res.pipe(stream);
    });
    await this.setCameraImage('front', this.homey.__("camera.front.title"), this.image);

    this.myDeviceApi.on('motion', track => {
      this.image.update().catch(this.error);
    });
  }
}