App

The App class is your start point for any app. This class should be extended and exported from app.js. Methods prefixed with on are meant to be overriden. It is not allowed to overwrite the constructor.

Example

/app.js

const Homey = require('homey');

class MyApp extends Homey.App {
  async onInit() {
    this.log('MyApp has been initialized');
  }
}

module.exports = MyApp;

Extends

Properties

homey

homey: Homey

The Homey instance of this app

Type

id

id: string

The app id

Type

  • string

manifest

manifest: any

The app.json manifest

Type

  • any

sdk

sdk: number

The app sdk version

Type

  • number

Methods

error

error(…args)

Log a message to the console (stderr)

Parameters

Name Type Description
args
* <repeatable>

log

log(…args)

Log a message to the console (stdout)

Parameters

Name Type Description
args
* <repeatable>

onInit

(async) onInit()

This method is called upon initialization of your app.

onUninit

(async) onUninit()

This method is called when your app is destroyed.