Add ActivityAccessory

This commit is contained in:
2023-03-16 14:09:20 +01:00
parent 663ce8b9b2
commit 90c728a2be
3 changed files with 111 additions and 1 deletions
+15
View File
@@ -11,6 +11,7 @@ import { environmentSensorAccessory } from './environmentSensorAccessory'
import { doorWindowSensorAccessory } from './doorWindowSensorAccessory'
import { motionSensorAccessory } from './motionSensorAccessory'
import { cameraAccessory } from './cameraAccessory'
import { activityAccessory } from './activityAccessory'
import { httpServer } from './httpServer'
export class domoticaPlatform implements DynamicPlatformPlugin {
@@ -111,6 +112,16 @@ export class domoticaPlatform implements DynamicPlatformPlugin {
.catch((error) => {
this.log.debug('cameraAccessory.discoverDevices Error ->' + error)
})
this.discoveryStarted('activityAccessory')
activityAccessory.discoverDevices(this)
.then((devices) => {
this.processDiscoveredDevices(devices)
this.discoveryCompleted('activityAccessory')
})
.catch((error) => {
this.log.debug('activityAccessory.discoverDevices Error ->' + error)
})
}
processDiscoveredDevices(domoticaDevices: device[]) {
@@ -143,6 +154,8 @@ export class domoticaPlatform implements DynamicPlatformPlugin {
this.accessories.push(new motionSensorAccessory(this, existingAccessory))
} else if (existingAccessory.context.device.type == 'Camera') {
this.accessories.push(new cameraAccessory(this, existingAccessory))
} else if (existingAccessory.context.device.type == 'Activity') {
this.accessories.push(new activityAccessory(this, existingAccessory))
}
} else {
this.log.info('+ ' + device.type + ': ' + device.deviceName)
@@ -164,6 +177,8 @@ export class domoticaPlatform implements DynamicPlatformPlugin {
this.accessories.push(new motionSensorAccessory(this, accessory))
} else if (accessory.context.device.type == 'Camera') {
this.accessories.push(new cameraAccessory(this, accessory))
} else if (accessory.context.device.type == 'Activity') {
this.accessories.push(new activityAccessory(this, accessory))
}
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory])