mirror of
https://github.com/dtwardow/homebridge-multi-tap-switch.git
synced 2026-11-02 05:18:30 +00:00
Configuration parameter to one location and configurable logger
This commit is contained in:
1 parent
a396e49c8e
commit
505b8b0a4a
5 files changed
+214
-80
No files matched your search
@@ -0,0 +1,69 @@
|
||||
import {PlatformConfig} from 'homebridge';
|
||||
|
||||
export interface PluginBaseConfig {
|
||||
Name: string;
|
||||
Enable: boolean;
|
||||
}
|
||||
|
||||
export interface PluginDeviceConfig {
|
||||
readonly name: string;
|
||||
readonly numberConfiguredScenes: number;
|
||||
readonly triggerTimeout: number;
|
||||
readonly resetAfterSwitchOff: boolean;
|
||||
readonly logging: boolean;
|
||||
}
|
||||
|
||||
export class PluginConfig {
|
||||
readonly Name: string;
|
||||
readonly Enable: boolean;
|
||||
readonly Devices: PluginDeviceConfig[];
|
||||
|
||||
constructor(config: PlatformConfig) {
|
||||
this.Name = config.name!;
|
||||
this.Enable = config.enable;
|
||||
|
||||
this.Devices = config.devices;
|
||||
}
|
||||
}
|
||||
|
||||
export class DeviceConfig {
|
||||
private device: PluginDeviceConfig;
|
||||
|
||||
constructor(item: PluginDeviceConfig) {
|
||||
this.device = item;
|
||||
}
|
||||
|
||||
Name() {
|
||||
return this.device.name;
|
||||
}
|
||||
|
||||
NumOfScenes() {
|
||||
return this.device.numberConfiguredScenes;
|
||||
}
|
||||
|
||||
TriggerTimeout() {
|
||||
return this.device.triggerTimeout;
|
||||
}
|
||||
|
||||
isResetWhenOff() {
|
||||
return this.device.resetAfterSwitchOff;
|
||||
}
|
||||
|
||||
isLogging() {
|
||||
return this.device.logging;
|
||||
}
|
||||
}
|
||||
|
||||
export interface AccessoryState {
|
||||
numberConfiguredScenes: number;
|
||||
triggerTimeout: number;
|
||||
//nextSceneToTrigger: number;
|
||||
}
|
||||
|
||||
export function initializeAccessoryState(initConfig: PluginDeviceConfig | AccessoryState): AccessoryState {
|
||||
return {
|
||||
numberConfiguredScenes: initConfig.numberConfiguredScenes,
|
||||
triggerTimeout: initConfig.triggerTimeout,
|
||||
//nextSceneToTrigger: 0,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user