"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
const path = require("path");
const fs = require("fs-extra");
let homebridge;
class HomebridgeGoogleSmartHome {
    constructor(log, config) {
        this.log = log;
        this.config = config;
        if (this.config.token) {
            this.start();
        }
    }
    start() {
        return __awaiter(this, void 0, void 0, function* () {
            const { Plugin } = yield Promise.resolve().then(() => require('./main'));
            const homebridgeConfig = yield fs.readJson(path.resolve(homebridge.user.configPath()));
            return new Plugin(this.log, this.config, homebridgeConfig);
        });
    }
    accessories(callback) {
        const accessories = [];
        callback(accessories);
    }
}
module.exports = (api) => {
    homebridge = api;
    homebridge.registerPlatform('homebridge-gsh', 'google-smarthome', HomebridgeGoogleSmartHome);
};
//# sourceMappingURL=index.js.map