Add new parameters to config schema.

This commit is contained in:
dennis committed 2026-03-09 21:29:53 +01:00
1 parent 62465b1deb
commit 3ef3435417
3 files changed
+44 -3

No files matched your search

+19 -3
View File
@@ -43,12 +43,19 @@
"required": true, "required": true,
"default": 10, "default": 10,
"minimum": 0, "minimum": 0,
"maximum": 30 "maximum": 60
}, },
"resetAfterSwitchOff": { "resetAfterSwitchOff": {
"title": "Reset when switch turned `Off`", "title": "Reset when switch is turned `Off`",
"type": "boolean", "type": "boolean",
"description": "Reset the switch and trigger index, when the trigger switch is turned <code>Off</code> (independent from timeout)", "description": "Reset the switch and trigger index, when the stateless switch is turned <code>Off</code>",
"required": true,
"default": false
},
"triggerSceneAfterSwitchOff": {
"title": "Trigger scene, when switch is turned `Off`",
"type": "boolean",
"description": "Trigger scene <code>0</code> (so called <code>Off</code>-scene), when the stateless switch is turned <code>Off</code> (independent from timeout).<br><b>Note:</b> If this is enabled, rotation starts from switch <code>1</code>, otherwise <code>0</code>.",
"required": true, "required": true,
"default": false "default": false
}, },
@@ -57,6 +64,15 @@
"type": "boolean", "type": "boolean",
"required": true, "required": true,
"default": false "default": false
},
"debounceTimerMs": {
"title": "Debounce Timer (in milliseconds)",
"type": "number",
"description": "Time to wait before the next switch trigger is accepted.<br>Only change this value, if you encounter problems using the HomeKit slider in the Home App",
"required": true,
"minimum": 10,
"maximum": 1000,
"default": 150
} }
} }
} }
+24
View File
@@ -3,14 +3,19 @@ import { PlatformConfig } from 'homebridge';
const DEFAULT_NUM_OF_CONFIGURED_SCENES = 5; const DEFAULT_NUM_OF_CONFIGURED_SCENES = 5;
const DEFAULT_TRIGGER_TIMEOUT = 10; const DEFAULT_TRIGGER_TIMEOUT = 10;
const DEFAULT_RESET_AFTER_SWITCH_OFF = false; const DEFAULT_RESET_AFTER_SWITCH_OFF = false;
const DEFAULT_TRIGGER_SCENE_AFTER_SWITCH_OFF = false;
const DEFAULT_TRIGGER_SCENE_OFF = 0;
const DEFAULT_LOGGING = false; const DEFAULT_LOGGING = false;
const DEFAULT_DEBOUNCE_TIMEOUT_MS = 150;
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 triggerSceneAfterSwitchOff?: boolean;
readonly logging?: boolean; readonly logging?: boolean;
readonly debounceTimerMs?: number;
} }
export class PluginConfig { export class PluginConfig {
@@ -50,10 +55,29 @@ export class DeviceConfig {
|| DEFAULT_RESET_AFTER_SWITCH_OFF; || DEFAULT_RESET_AFTER_SWITCH_OFF;
} }
isTriggerSceneWhenOff(): boolean {
return this.device.triggerSceneAfterSwitchOff
|| DEFAULT_TRIGGER_SCENE_AFTER_SWITCH_OFF;
}
// When triggerSceneAfterSwitchOff is 'true', start at 1, otherwise 0 (normal behavior)
FirstTriggerScene(): number {
return this.isTriggerSceneWhenOff() ? 1 : 0;
}
TriggerOffSceneIndex(): number {
return DEFAULT_TRIGGER_SCENE_OFF;
}
isLogging(): boolean { isLogging(): boolean {
return this.device.logging return this.device.logging
|| DEFAULT_LOGGING; || DEFAULT_LOGGING;
} }
DebounceTimeoutMs(): number {
return this.device.debounceTimerMs
|| DEFAULT_DEBOUNCE_TIMEOUT_MS;
}
} }
export interface AccessoryState { export interface AccessoryState {
+1
View File
@@ -34,6 +34,7 @@
"numberConfiguredScenes": 5, "numberConfiguredScenes": 5,
"triggerTimeout": 10, "triggerTimeout": 10,
"resetAfterSwitchOff": false, "resetAfterSwitchOff": false,
"triggerSceneAfterSwitchOff": true,
"logging": true "logging": true
} }
] ]