Homey

The Homey instance holds all the Managers, System Events and generic properties. You can access the Homey instance through this.homey on App, Driver and Device, it is also passed into your api handlers.

Table of Contents

Example
// register system events
this.homey.on('memwarn', () => console.log('memwarn!'));

// access a Manager
const latitude = this.homey.geolocation.getLatitude();
console.log('Latitude: ', latitude);

Extends

Properties

api

Gives access to ManagerApi

apps

Gives access to ManagerApps

arp

Gives access to ManagerArp

audio

Gives access to ManagerAudio

ble

Gives access to ManagerBLE

clock

Gives access to ManagerClock

cloud

Gives access to ManagerCloud

discovery

Gives access to ManagerDiscovery

drivers

Gives access to ManagerDrivers

flow

Gives access to ManagerFlow

geolocation

Gives access to ManagerGeolocation

i18n

Gives access to ManagerI18n

images

Gives access to ManagerImages

insights

Gives access to ManagerInsights

ledring

Gives access to ManagerLedring

manifest :object

The app.json manifest

Type:
  • object

nfc

Gives access to ManagerNFC

notifications

Gives access to ManagerNotifications

rf

Gives access to ManagerRF

settings

Gives access to ManagerSettings

speechInput

Gives access to ManagerSpeechInput

speechOutput

Gives access to ManagerSpeechOutput

version :string

The software version of the Homey that is running this app

Type:
  • string

zigbee

Gives access to ManagerZigBee

zwave

Gives access to ManagerZwave

Methods

__(key)

Shortcut to ManagerI18n#__

Parameters:
Name Type Description
key string | Object

or i18n Object

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

clearInterval(timeoutId)

Alias to clearInterval

Parameters:
Name Type Description
timeoutId any

clearTimeout(timeoutId)

Alias to clearTimeout

Parameters:
Name Type Description
timeoutId any

error(…args)

Log a message to the console (stderr)

Overrides:
Parameters:
Name Type Attributes Description
args * <repeatable>

log(…args)

Log a message to the console (stdout)

Overrides:
Parameters:
Name Type Attributes Description
args * <repeatable>

setInterval(callback, ms, …args)

Alias to setInterval that ensures the interval is correctly disposed of when the Homey instance gets destroyed

Parameters:
Name Type Attributes Description
callback function
ms number
args any <repeatable>

setTimeout(callback, ms, …args)

Alias to setTimeout that ensures the timout is correctly disposed of when the Homey instance gets destroyed

Parameters:
Name Type Attributes Description
callback function
ms number
args any <repeatable>

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.