All properties & methods in this namespace are accessible in a HomeyScript.
Example
// Get all devices
const devices = await Homey.devices.getDevices();
// Loop over all devices
for (const device of Object.values(devices)) {
// If this device is a light (class)
// Or this is a 'What's plugged in?'-light (virtualClass)
if (device.class === 'light' || device.virtualClass === 'light') {
log(`\nTurning '${device.name}' on...`);
// Turn the light on by setting the capability `onoff` to `true`
await device.setCapabilityValue('onoff', true)
.then(() => log('OK'))
.catch(error => log(`Error:`, error));
}
}
Properties
_
(static) _: Object__filename__
(static) __filename__: StringThe filename of the HomeyScript.
Type
- String
__last_executed__
(static) __last_executed__: DateWhen the HomeyScript has last executed.
Type
- Date
__ms_since_last_executed__
(static) __ms_since_last_executed__: NumberMilliseconds since the HomeyScript has last executed.
Type
- Number
__script_id__
(static) __script_id__: StringThe Script ID of the HomeyScript.
Type
- String
args
(static) args: ArrayProvided arguments to this script.
Type
- Array
Example
log(args[0]); // "myArgument"
Buffer
(static) Buffer: ObjectHomey
(static) Homey: HomeyAPIhttp
(static) http: Objecthttps
(static) https: ObjectURLSearchParams
(static) URLSearchParams: ClassMethods
fetch
(async, static) fetch(url, options)Shortcut to node-fetch.
Parameters
Name | Type | Description |
---|---|---|
url
|
String | |
options
|
Object |
get
(static) get(key)Get a global value that's accessible between HomeyScripts.
Parameters
Name | Type | Description |
---|---|---|
key
|
String | Key of the property |
keys
(static) keys(): ArrayGets all keys of global values.
Returns
Array
log
(async, static) log(…arg1)Log to the console.
Parameters
Name | Type | Description |
---|---|---|
arg1
|
Mixed
<repeatable> |
Example
log('Hello World!');
say
(async, static) say(text)Says something over the internal speaker.
Parameters
Name | Type | Description |
---|---|---|
text
|
String |
Example
await say('Hello world!');
set
(static) set(key, value)Set a global value that's accessible between HomeyScripts.
Parameters
Name | Type | Description |
---|---|---|
key
|
String | Key of the property |
value
|
Mixed | Value of the property |
tag
(async, static) tag(id, value)Creates or updates a Flow Tag. These are persistent across reboots.
Delete a Flow Tag by providing null
as value.
Parameters
Name | Type | Description |
---|---|---|
id
|
String | ID of the Tag |
value
|
String | Number | Boolean | null | Value of the Tag |
Example
await tag('My Tag', 1337); // Create
await tag('My Tag', 1338); // Update
await tag('My Tag', null); // Delete
wait
(async, static) wait(milliseconds)Resolves after milliseconds
milliseconds.
Parameters
Name | Type | Description |
---|---|---|
milliseconds
|
Number |
Example
log('Foo');
await wait(1000);
log('Bar');