homebridge-homeconnect
Version:
A Homebridge plugin that connects Home Connect appliances to Apple HomeKit
42 lines • 2.04 kB
JavaScript
// Homebridge plugin for Home Connect home appliances
// Copyright © 2023-2025 Alexander Thoukydides
import { ClientLogger, ServerLogger } from './logger.js';
import { Config } from './config.js';
import { Cards } from './cards.js';
import { ClientClientID } from './client-clientid.js';
import { FormId, Forms } from './forms.js';
import { ClientIPC } from './client-ipc.js';
import { APIStatus } from './api-status.js';
// A Homebridge HomeConnect custom UI client
class Client {
// Create a new custom UI client
constructor() {
// Create a local logger and IPC client
this.log = new ClientLogger();
this.log.debug('homebridge.plugin', window.homebridge.plugin);
this.ipc = new ClientIPC(this.log);
// Wait for the server before continuing initialisation
this.ipc.onEvent('ready', () => { this.serverReady(); });
}
// The server is ready so finish initialising the client
serverReady() {
// Start receiving (important) log messages from the server
this.serverLog = new ServerLogger(this.ipc, "warn" /* LogLevel.WARN */);
// Create all of the required resources
const config = new Config(this.log, this.ipc);
const forms = new Forms(this.log, this.ipc, config);
const cards = new Cards(this.log);
const client = new ClientClientID(this.log, this.ipc);
new APIStatus(this.log);
// Create cards for the global settings and each available appliance
cards.setNonAppliances([{ id: FormId.Global, icon: 'global', name: 'General Settings' }]);
client.onAppliances = (appliances) => { cards.setAppliances(appliances ?? []); };
cards.onSelect = (id) => { forms.showForm(id); };
// Attempt to authorise a client when the configuration changes
config.onGlobal = (config) => { client.setClient(config); };
client.onFail = () => { forms.showForm(FormId.Global); };
}
}
// Create a custom UI client instance
new Client();
//# sourceMappingURL=client.js.map