HomeyAPIApp

Use this class to utilize Homey Pro's Web API from inside an app.

This class only works on apps using Apps SDK v3 running on Homey Pro.

Make sure your app has the homey:manager:api permission.

Constructor

HomeyAPIApp

new HomeyAPIApp(homey, debugopt)

Parameters

Name Type Description
homey
Homey

The Homey instance of your app, usually this.homey.

debug
boolean <optional>
default:false

Enable debug logs.

Example

// app.json
{
  ...
  "platforms": [ "local" ],
  "permissions": [ "homey:manager:api" ],
}

// app.js
const Homey = require('homey');
const { HomeyAPIApp } = require('homey-api');

class MyApp extends Homey.App {

  async onInit() {
    const api = new HomeyAPIApp({
      homey: this.homey,
    });

    const devices = await api.devices.getDevices();
    this.log('Devices:', devices);
  }

}

Extends

Properties

DISCOVERY_STRATEGIES

DISCOVERY_STRATEGIES

Possible Discovery Strategies

Properties

Name Type Description
DISCOVERY_STRATEGIES
object
LOCAL
string

Local HTTP, e.g. http://192.168.1.100.

}

Methods

__

__(input): string|null

Translates an i18n-object (e.g. { en: 'My String', nl: 'Mijn tekst' } to a string. Uses the language of Homey as defined in Homey.

Parameters

Name Type Description
input
object
en
string

English translation

nl
string

Dutch translation

}

Returns

  • The translated string, or null
string | null

Example

homeyApi.__({
  en: 'Hello',
  nl: 'Hallo',
  fr: 'Bonjour',
}); // returns "Hello" if Homey is set to English

isConnected

isConnected(): Boolean

If Homey is connected to Socket.io.

Returns

Boolean