Images
Images can be used in various places throughout Homey, such as album art for speakers, camera devices and in Flows.
When an Image is created, it needs a way of providing Homey with its data. This can be either:
an URL, available from anywhere on the internet
a binary stream through the
getStreammethoda local path to a static image which is shipped with the App.
Note: Images are limited to 5 MB.
Creating an image
Using an URL
URLs should be used when the image is available publicly on the internet.
const Homey = require('homey');
class App extends Homey.App {
async onInit() {
const myImage = await this.homey.images.createImage();
// the URL must start with https://
myImage.setUrl("https://www.example.com/image.png");
}
}
module.exports = App;Using a Stream
Streams should be used when downloading an image that cannot be supplied using Image#setUrl(). Using image streams involves writing data directly into a Node.js stream. Using streams requires homey version 2.2.0 or higher.
Using a Path
Paths should be used when the image is locally available.
Updating the image
Call Image#update() when the image has been updated, and the front-end will download the image again.
When your image uses a Stream, the method provided in Image#setStream() will be called again.
At any time, you can switch between delivery type by calling Image#setPath(), Image#setStream() or Image#setURL().
Retrieving an image
It is also possible to consume an image in your app, for instance through use of Flow Tokens.
Last updated
Was this helpful?