Homey

const Homey = require('homey');

Table of Contents

The Homey module should be required in every file of your app. It gives access to Managers, Classes, System Events and generic properties. It is automatically available when running an App on Homey.

Properties:
Name Type Description
app App

A pointer to the App's instance.

manifest Object

The /app.json as Object.

dir string

The root directory of the app.

Example
const Homey = require('homey');

// register system events
Homey.on('memwarn', () => {
    this.log('memwarn!');
});

// get a Manager
const { ManagerGeolocation } = Homey;
const latitude = ManagerGeolocation.getLatitude();
console.log('Latitude: ', latitude);

Extends

  • EventEmitter

Methods

__(key)

Shortcut to ManagerI18n#__.

Parameters:
Name Type Description
key string | Object

or i18n Object

Examples
Homey.__('errors.device_unavailable');
Homey.__({
 en: 'My String',
 nl: 'Mijn tekst',
});

Events

.on('cpuwarn')

Fires when the app is using too much CPU. When the app does not behave within reasonable amount of time, the app is killed.

Parameters:
Name Type Description
data Object
Name Type Description
count number

The number of warnings already sent.

limit number

The number of maximum warnings until the app is killed.

.on('memwarn')

Fires when the app is using too much memory. When the app does not behave within reasonable amount of time, the app is killed.

Parameters:
Name Type Description
data Object
Name Type Description
count number

The number of warnings already sent.

limit number

The number of maximum warnings until the app is killed.

.on('unload')

Fires when the app is being unloaded. When a listener is attached to this event, the app is delayed 1s so there's time to close connection, save data etc.