Image Tokens

Certain applications might want to share images between Flows, e.g. a webcam that made a snapshot, or a Chromecast that wants to cast an image. A image typed token can be used here.

To start using image tokens, first register a Image instance.


let myImage = await this.homey.images.createImage();
myImage.setPath(path.join(__dirname, 'assets', 'images', 'kitten.jpg'));

// create a token & register it
let myImageToken = await this.homey.flow.createToken('my_token', {
  type: 'image',
  title: 'My Image Token'

await myImageToken.setValue(myImage);

// listen for a Flow action
const myActionCard = this.homey.flow.getActionCard('image_action');

myActionCard.registerRunListener(async (args, state) => {
  // get the contents of the image
  const imageStream = await args.droptoken.getStream();
  this.log('saving image of mime type:', imageStream.contentType, 'to: ', imageStream.filename)
  // save the image
  const targetFile = fs.createWriteStream(path.join(__dirname, 'userdata', filename));
  return true;

// trigger a Flow
const myTriggerCard = this.homey.flow.getTriggerCard('image_trigger');

await myTriggerCard.trigger({
  my_image: myImage // pass the instance here