mirror of
https://github.com/dtwardow/homebridge-multi-tap-switch.git
synced 2026-11-01 20:18:30 +00:00
Multiple devices per platform
This commit is contained in:
1 parent
232d38ac8c
commit
a396e49c8e
2 files changed
+21
-14
No files matched your search
+14
-9
@@ -3,25 +3,30 @@
|
||||
"pluginType": "platform",
|
||||
"singular": true,
|
||||
"schema": {
|
||||
"devices": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"title": "Switch",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"title": "Name",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"default": "Scene Switcher"
|
||||
"required": true
|
||||
},
|
||||
"numScenes": {
|
||||
"title": "Number of Scenes",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"default": 4
|
||||
},
|
||||
"secondsToKeep": {
|
||||
"title": "Holding Time",
|
||||
"title": "Max. Scenes",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"default": 5
|
||||
},
|
||||
"secondsToKeep": {
|
||||
"title": "Reset Timeout",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"default": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-5
@@ -65,14 +65,15 @@ export class MultiTapSwitchPlatform implements DynamicPlatformPlugin {
|
||||
}
|
||||
|
||||
discoverDevices() {
|
||||
const uuid = this.defineUuid(this.config.name, '0');
|
||||
|
||||
for (let i = 0; i < this.config.devices.length; i++) {
|
||||
const accessoryConfig: PlatformConfigData = {
|
||||
Name: this.config.name ? this.config.name : 'Scene Switch',
|
||||
MaxNumScenes: this.config.numScenes,
|
||||
SecondsBeforeReset: this.config.secondsToKeep,
|
||||
Name: this.config.devices[i].name,
|
||||
MaxNumScenes: this.config.devices[i].numScenes,
|
||||
SecondsBeforeReset: this.config.devices[i].secondsToKeep,
|
||||
};
|
||||
|
||||
const uuid = this.defineUuid(accessoryConfig.Name, '0');
|
||||
|
||||
// see if an accessory with the same uuid has already been registered and restored from
|
||||
// the cached devices we stored in the `configureAccessory` method above
|
||||
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
||||
@@ -112,3 +113,4 @@ export class MultiTapSwitchPlatform implements DynamicPlatformPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user