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.

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

api: ManagerApi

Type

app

app: App

A pointer to the App's instance.

Type

apps

apps: ManagerApps

arp

arp: ManagerArp

Type

audio

audio: ManagerAudio

ble

ble: ManagerBLE

Type

clock

clock: ManagerClock

cloud

cloud: ManagerCloud

discovery

discovery: ManagerDiscovery

drivers

drivers: ManagerDrivers

env

env: any

The env.json environment variables

Type

  • any

flow

flow: ManagerFlow

geolocation

geolocation: ManagerGeolocation

i18n

i18n: ManagerI18n

images

images: ManagerImages

insights

insights: ManagerInsights

ledring

ledring: ManagerLedring

manifest

manifest: any

The app.json manifest

Type

  • any

nfc

nfc: ManagerNFC

Type

notifications

notifications: ManagerNotifications

rf

rf: ManagerRF

Type

settings

settings: ManagerSettings

speechInput

speechInput: ManagerSpeechInput

speechOutput

speechOutput: ManagerSpeechOutput

version

version: string

The software version of the Homey that is running this app

Type

  • string

zigbee

zigbee: ManagerZigBee

zwave

zwave: ManagerZwave

Methods

__

__(key, tagsopt): string

Shortcut to ManagerI18n#__

Parameters

Name Type Description
key
string | Object

translation string or Object

tags
Object <optional>

values to interpolate into the translation

Returns

string

Examples

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

clearInterval

clearInterval(timeoutId)

Alias to clearInterval

Parameters

Name Type Description
timeoutId
any

clearTimeout

clearTimeout(timeoutId)

Alias to clearTimeout

Parameters

Name Type Description
timeoutId
any

error

error(…args)

Log a message to the console (stderr)

Parameters

Name Type Description
args
* <repeatable>

hasPermission

hasPermission(permission): boolean

Parameters

Name Type Description
permission
string

Returns

boolean

log

log(…args)

Log a message to the console (stdout)

Parameters

Name Type Description
args
* <repeatable>

setInterval

setInterval(callback, ms, …args)

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

Parameters

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

setTimeout

setTimeout(callback, ms, …args)

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

Parameters

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

Events

cpuwarn

.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
count
number

The number of warnings already sent.

limit
number

The number of maximum warnings until the app is killed.

}

memwarn

.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
count
number

The number of warnings already sent.

limit
number

The number of maximum warnings until the app is killed.

}

unload

.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.