const Homey = require('homey');
class App extends Homey.App {
const myImage = await this.homey.images.createImage();
myImage.setPath(path.join(__dirname, "assets", "images", "kitten.jpg"));
// create a token & register it
const myImageToken = await this.homey.flow.createToken("my_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 ${imageStream.contentType} to: ${imageStream.filename}`);
const targetFile = fs.createWriteStream(
path.join(__dirname, "userdata", filename)
imageStream.pipe(targetFile);
const myTriggerCard = this.homey.flow.getTriggerCard("image_trigger");
// pass the image to the trigger call
await myTriggerCard.trigger({ my_image: myImage });