mirror of
https://github.com/dtwardow/homebridge-multi-tap-switch.git
synced 2026-11-01 20:18:30 +00:00
Trigger Timeout handling updated
This commit is contained in:
1 parent
ac935d9cf5
commit
0134932ba3
3 files changed
+18
-6
No files matched your search
@@ -8,10 +8,6 @@ This plugin provides a switch, which can be triggered multiple times to trigger
|
|||||||
|
|
||||||
Actions could be everything, which can be configured within **Automations**.
|
Actions could be everything, which can be configured within **Automations**.
|
||||||
|
|
||||||
## History
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## How it works?
|
## How it works?
|
||||||
|
|
||||||
The plugin provides a virtual **switch** which can be triggered manually (which doesn't really make sense) or
|
The plugin provides a virtual **switch** which can be triggered manually (which doesn't really make sense) or
|
||||||
@@ -46,12 +42,11 @@ The configuration allows the user to add multiple **Multi-Tap-Switches**. The fo
|
|||||||
| `devices[] .logging` | false | | Logging of switch/trigger actions. |
|
| `devices[] .logging` | false | | Logging of switch/trigger actions. |
|
||||||
|
|
||||||
The parameter ```triggerTimeout``` can be changed in the configuration during runtime. So, this is just the initial value.
|
The parameter ```triggerTimeout``` can be changed in the configuration during runtime. So, this is just the initial value.
|
||||||
If the value is set to `0`, the switch will never reset. This can be also combined with the ```resetAfterSwitchOff``` parameter.
|
|
||||||
|
|
||||||
The parameter ```numberConfiguredScenes``` just defines how many **programmable** switches are available (currently, there is no limit). The number of
|
The parameter ```numberConfiguredScenes``` just defines how many **programmable** switches are available (currently, there is no limit). The number of
|
||||||
really **used** switches can configured during runtime, between 0 and the configured number.
|
really **used** switches can configured during runtime, between 0 and the configured number.
|
||||||
|
|
||||||
> **NOTE:** Additional parameters (also called **Characteristics**) can only be configured via 3rd-party HomeKit apps, but in the basic Home App!
|
> **NOTE:** Additional parameters (also called **Characteristics**) can only be configured via 3rd-party HomeKit apps, but not in the basic Home App!
|
||||||
|
|
||||||
So, an example **platform** plugin config will look as follows:
|
So, an example **platform** plugin config will look as follows:
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export interface AccessoryState {
|
|||||||
numberConfiguredScenes: number;
|
numberConfiguredScenes: number;
|
||||||
triggerTimeout: number;
|
triggerTimeout: number;
|
||||||
//nextSceneToTrigger: number;
|
//nextSceneToTrigger: number;
|
||||||
|
triggerTimeoutManuallyChanged: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initializeAccessoryState(initConfig: PluginDeviceConfig | AccessoryState): AccessoryState {
|
export function initializeAccessoryState(initConfig: PluginDeviceConfig | AccessoryState): AccessoryState {
|
||||||
@@ -67,5 +68,6 @@ export function initializeAccessoryState(initConfig: PluginDeviceConfig | Access
|
|||||||
numberConfiguredScenes: initConfig.numberConfiguredScenes || DEFAULT_NUM_OF_CONFIGURED_SCENES,
|
numberConfiguredScenes: initConfig.numberConfiguredScenes || DEFAULT_NUM_OF_CONFIGURED_SCENES,
|
||||||
triggerTimeout: initConfig.triggerTimeout || DEFAULT_TRIGGER_TIMEOUT,
|
triggerTimeout: initConfig.triggerTimeout || DEFAULT_TRIGGER_TIMEOUT,
|
||||||
//nextSceneToTrigger: 0,
|
//nextSceneToTrigger: 0,
|
||||||
|
triggerTimeoutManuallyChanged: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -81,6 +81,12 @@ export class DeviceAccessory {
|
|||||||
.updateValue(this.State.numberConfiguredScenes);
|
.updateValue(this.State.numberConfiguredScenes);
|
||||||
|
|
||||||
// Register handlers for the TriggerTimeout characteristic & restore previous value
|
// Register handlers for the TriggerTimeout characteristic & restore previous value
|
||||||
|
if (!this.State.triggerTimeoutManuallyChanged) {
|
||||||
|
this.State.triggerTimeout = this.Config.TriggerTimeout();
|
||||||
|
} else {
|
||||||
|
this.Log.debug('Current Trigger Timeout [' + this.State.triggerTimeout + '] differs from configured value [' +
|
||||||
|
this.Config.TriggerTimeout() + ']. It won\'t be updated until it\'s equal again.');
|
||||||
|
}
|
||||||
(this.serviceIn.getCharacteristic(this.platform.Characteristic.TriggerTimeout)
|
(this.serviceIn.getCharacteristic(this.platform.Characteristic.TriggerTimeout)
|
||||||
|| this.serviceIn.addOptionalCharacteristic(this.platform.Characteristic.TriggerTimeout))
|
|| this.serviceIn.addOptionalCharacteristic(this.platform.Characteristic.TriggerTimeout))
|
||||||
.setProps({
|
.setProps({
|
||||||
@@ -251,6 +257,15 @@ export class DeviceAccessory {
|
|||||||
'Set Trigger Timeout ->', triggerTimeout, '-> Out-of-Range / Value must be greater or equal to 0');
|
'Set Trigger Timeout ->', triggerTimeout, '-> Out-of-Range / Value must be greater or equal to 0');
|
||||||
triggerTimeout = 0;
|
triggerTimeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.State.triggerTimeoutManuallyChanged = (this.Config.TriggerTimeout() !== triggerTimeout);
|
||||||
|
if (!this.State.triggerTimeoutManuallyChanged) {
|
||||||
|
this.Log.debug('Trigger Timeout in sync with config.');
|
||||||
|
} else {
|
||||||
|
this.Log.warn('Trigger Timeout not in sync with config value [' + this.Config.TriggerTimeout() + '].');
|
||||||
|
this.Log.warn('It will not be updated by config changes, until it is in sync again!');
|
||||||
|
}
|
||||||
|
|
||||||
this.State.triggerTimeout = triggerTimeout;
|
this.State.triggerTimeout = triggerTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user