mirror of
https://github.com/dtwardow/homebridge-multi-tap-switch.git
synced 2026-11-01 20:18:30 +00:00
Check that characteristic value are in their specified range
This commit is contained in:
1 parent
65ef31b84a
commit
381a29ec06
1 file changed
+24
-5
@@ -72,7 +72,7 @@ export class DeviceAccessory {
|
|||||||
(this.serviceIn.getCharacteristic(this.platform.Characteristic.ConfiguredScenes)
|
(this.serviceIn.getCharacteristic(this.platform.Characteristic.ConfiguredScenes)
|
||||||
|| this.serviceIn.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredScenes))
|
|| this.serviceIn.addOptionalCharacteristic(this.platform.Characteristic.ConfiguredScenes))
|
||||||
.setProps({
|
.setProps({
|
||||||
'minValue': 0,
|
'minValue': 1,
|
||||||
'maxValue': this.Config.NumOfScenes(),
|
'maxValue': this.Config.NumOfScenes(),
|
||||||
'minStep': 1,
|
'minStep': 1,
|
||||||
})
|
})
|
||||||
@@ -209,8 +209,20 @@ export class DeviceAccessory {
|
|||||||
* @param value Number of active switches
|
* @param value Number of active switches
|
||||||
*/
|
*/
|
||||||
async setItemsToHandle(value: CharacteristicValue) {
|
async setItemsToHandle(value: CharacteristicValue) {
|
||||||
const numItemsToHandle = value as number;
|
let numItemsToHandle = value as number;
|
||||||
this.Log.debug('Set Characteristic NumScenes ->', numItemsToHandle);
|
|
||||||
|
if ((numItemsToHandle > 0) && (numItemsToHandle <= this.Config.NumOfScenes())) {
|
||||||
|
this.Log.log('Set number of Active Switches ->', numItemsToHandle);
|
||||||
|
} else {
|
||||||
|
this.Log.warn(
|
||||||
|
'Set number of Active Switches ->', numItemsToHandle, '-> Out-of-Range / Value must be between 1 and', this.Config.NumOfScenes());
|
||||||
|
if (numItemsToHandle > this.Config.NumOfScenes()) {
|
||||||
|
numItemsToHandle = this.Config.NumOfScenes();
|
||||||
|
} else {
|
||||||
|
numItemsToHandle = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.State.numberConfiguredScenes = numItemsToHandle;
|
this.State.numberConfiguredScenes = numItemsToHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +240,15 @@ export class DeviceAccessory {
|
|||||||
* @param value Time in seconds
|
* @param value Time in seconds
|
||||||
*/
|
*/
|
||||||
async setTriggerTimeout(value: CharacteristicValue) {
|
async setTriggerTimeout(value: CharacteristicValue) {
|
||||||
const triggerTimeout = value as number;
|
let triggerTimeout = value as number;
|
||||||
this.Log.log('Set Trigger Timeout ->', triggerTimeout);
|
|
||||||
|
if (triggerTimeout >= 0) {
|
||||||
|
this.Log.log('Set Trigger Timeout ->', triggerTimeout);
|
||||||
|
} else {
|
||||||
|
this.Log.warn(
|
||||||
|
'Set Trigger Timeout ->', triggerTimeout, '-> Out-of-Range / Value must be greater or equal to 0');
|
||||||
|
triggerTimeout = 0;
|
||||||
|
}
|
||||||
this.State.triggerTimeout = triggerTimeout;
|
this.State.triggerTimeout = triggerTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user