mirror of
https://github.com/dtwardow/homebridge-multi-tap-switch.git
synced 2026-11-02 05:18:30 +00:00
Add default values to config.ts
This commit is contained in:
1 parent
6ef1507d79
commit
1a4cef059a
1 file changed
+24
-15
+24
-15
@@ -1,11 +1,16 @@
|
|||||||
import {PlatformConfig} from 'homebridge';
|
import {PlatformConfig} from 'homebridge';
|
||||||
|
|
||||||
|
const DEFAULT_NUM_OF_CONFIGURED_SCENES = 5;
|
||||||
|
const DEFAULT_TRIGGER_TIMEOUT = 10;
|
||||||
|
const DEFAULT_RESET_AFTER_SWITCH_OFF = false;
|
||||||
|
const DEFAULT_LOGGING = false;
|
||||||
|
|
||||||
export interface PluginDeviceConfig {
|
export interface PluginDeviceConfig {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly numberConfiguredScenes: number;
|
readonly numberConfiguredScenes?: number;
|
||||||
readonly triggerTimeout: number;
|
readonly triggerTimeout?: number;
|
||||||
readonly resetAfterSwitchOff: boolean;
|
readonly resetAfterSwitchOff?: boolean;
|
||||||
readonly logging: boolean;
|
readonly logging?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PluginConfig {
|
export class PluginConfig {
|
||||||
@@ -26,24 +31,28 @@ export class DeviceConfig {
|
|||||||
this.device = item;
|
this.device = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
Name() {
|
Name(): string {
|
||||||
return this.device.name;
|
return this.device.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
NumOfScenes() {
|
NumOfScenes(): number {
|
||||||
return this.device.numberConfiguredScenes;
|
return this.device.numberConfiguredScenes
|
||||||
|
|| DEFAULT_NUM_OF_CONFIGURED_SCENES;
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerTimeout() {
|
TriggerTimeout(): number {
|
||||||
return this.device.triggerTimeout;
|
return this.device.triggerTimeout
|
||||||
|
|| DEFAULT_TRIGGER_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
isResetWhenOff() {
|
isResetWhenOff(): boolean {
|
||||||
return this.device.resetAfterSwitchOff;
|
return this.device.resetAfterSwitchOff
|
||||||
|
|| DEFAULT_RESET_AFTER_SWITCH_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
isLogging() {
|
isLogging(): boolean {
|
||||||
return this.device.logging;
|
return this.device.logging
|
||||||
|
|| DEFAULT_LOGGING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +64,8 @@ export interface AccessoryState {
|
|||||||
|
|
||||||
export function initializeAccessoryState(initConfig: PluginDeviceConfig | AccessoryState): AccessoryState {
|
export function initializeAccessoryState(initConfig: PluginDeviceConfig | AccessoryState): AccessoryState {
|
||||||
return {
|
return {
|
||||||
numberConfiguredScenes: initConfig.numberConfiguredScenes,
|
numberConfiguredScenes: initConfig.numberConfiguredScenes || DEFAULT_NUM_OF_CONFIGURED_SCENES,
|
||||||
triggerTimeout: initConfig.triggerTimeout,
|
triggerTimeout: initConfig.triggerTimeout || DEFAULT_TRIGGER_TIMEOUT,
|
||||||
//nextSceneToTrigger: 0,
|
//nextSceneToTrigger: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user