From cef9987df1daa91231765d91c7bb696e09eb7169 Mon Sep 17 00:00:00 2001 From: Flavio De Stefano Date: Tue, 27 Aug 2024 12:59:23 +0200 Subject: [PATCH] Removing setup --- src/cameraAccessory.ts | 131 +++++++++++++++++++++-------------------- src/tapoCamera.ts | 12 ++-- 2 files changed, 73 insertions(+), 70 deletions(-) diff --git a/src/cameraAccessory.ts b/src/cameraAccessory.ts index 889170e..511517b 100644 --- a/src/cameraAccessory.ts +++ b/src/cameraAccessory.ts @@ -254,69 +254,72 @@ export class CameraAccessory { } async setup() { - const cameraInfo = await this.camera.getDeviceInfo(); - this.accessory.on(PlatformAccessoryEvent.IDENTIFY, () => { - this.log.info("Identify requested", cameraInfo); - }); - - this.log.debug("Camera info", cameraInfo); - - this.setupInfoAccessory(cameraInfo); - - if (!this.config.disableStreaming) { - this.setupCameraStreaming(cameraInfo); - } - - if (!this.config.disableEyesToggleAccessory) { - this.setupToggleAccessory( - this.config.eyesToggleAccessoryName || "Eyes", - "eyes" - ); - } - - if (!this.config.disableAlarmToggleAccessory) { - this.setupToggleAccessory( - this.config.alarmToggleAccessoryName || "Alarm", - "alarm" - ); - } - - if (!this.config.disableNotificationsToggleAccessory) { - this.setupToggleAccessory( - this.config.notificationsToggleAccessoryName || "Notifications", - "notifications" - ); - } - - if (!this.config.disableMotionDetectionToggleAccessory) { - this.setupToggleAccessory( - this.config.motionDetectionToggleAccessoryName || "Motion Detection", - "motionDetection" - ); - } - - if (!this.config.disableLEDToggleAccessory) { - this.setupToggleAccessory( - this.config.ledToggleAccessoryName || "LED", - "led" - ); - } - - if (!this.config.disableMotionSensorAccessory) { - this.setupMotionSensorAccessory(); - } - - // Publish as external accessory - this.log.debug("Publishing accessory..."); - this.api.publishExternalAccessories(PLUGIN_ID, [this.accessory]); - - this.log.debug("Notifying initial values..."); - await this.getStatusAndNotify(); - - // Setup the polling by giving a 3s random delay - // to avoid all the cameras starting at the same time - setTimeout(() => { - this.setupPolling(); - }, this.randomSeed * 5000); + const basicInfo = await this.camera.getBasicInfo(); + this.log.debug("Basic info", basicInfo); + + // const cameraInfo = await this.camera.getDeviceInfo(); + // this.accessory.on(PlatformAccessoryEvent.IDENTIFY, () => { + // this.log.info("Identify requested", cameraInfo); + // }); + + // this.log.debug("Camera info", cameraInfo); + + // this.setupInfoAccessory(cameraInfo); + + // if (!this.config.disableStreaming) { + // this.setupCameraStreaming(cameraInfo); + // } + + // if (!this.config.disableEyesToggleAccessory) { + // this.setupToggleAccessory( + // this.config.eyesToggleAccessoryName || "Eyes", + // "eyes" + // ); + // } + + // if (!this.config.disableAlarmToggleAccessory) { + // this.setupToggleAccessory( + // this.config.alarmToggleAccessoryName || "Alarm", + // "alarm" + // ); + // } + + // if (!this.config.disableNotificationsToggleAccessory) { + // this.setupToggleAccessory( + // this.config.notificationsToggleAccessoryName || "Notifications", + // "notifications" + // ); + // } + + // if (!this.config.disableMotionDetectionToggleAccessory) { + // this.setupToggleAccessory( + // this.config.motionDetectionToggleAccessoryName || "Motion Detection", + // "motionDetection" + // ); + // } + + // if (!this.config.disableLEDToggleAccessory) { + // this.setupToggleAccessory( + // this.config.ledToggleAccessoryName || "LED", + // "led" + // ); + // } + + // if (!this.config.disableMotionSensorAccessory) { + // this.setupMotionSensorAccessory(); + // } + + // // Publish as external accessory + // this.log.debug("Publishing accessory..."); + // this.api.publishExternalAccessories(PLUGIN_ID, [this.accessory]); + + // this.log.debug("Notifying initial values..."); + // await this.getStatusAndNotify(); + + // // Setup the polling by giving a 3s random delay + // // to avoid all the cameras starting at the same time + // setTimeout(() => { + // this.setupPolling(); + // }, this.randomSeed * 5000); } } diff --git a/src/tapoCamera.ts b/src/tapoCamera.ts index 529f7b3..59a0cf4 100644 --- a/src/tapoCamera.ts +++ b/src/tapoCamera.ts @@ -213,7 +213,7 @@ export class TAPOCamera extends OnvifCamera { ); if (response.status === 401 && responseData.result?.data?.code === 40411) { - this.log.debug("StokRefresh: Invalid credentials, code 40411"); + this.log.debug("refreshStok: Invalid credentials, code 40411"); throw new Error("Invalid credentials"); } @@ -277,10 +277,10 @@ export class TAPOCamera extends OnvifCamera { responseData?.result?.data?.sec_left && responseData.result.data.sec_left > 0 ) { - this.log.debug("StokRefresh: Temporary Suspension", responseData); + this.log.debug("refreshStok: Temporary Suspension", responseData); throw new Error( - `StokRefresh: Temporary Suspension: Try again in ${responseData.result.data.sec_left} seconds` + `refreshStok: Temporary Suspension: Try again in ${responseData.result.data.sec_left} seconds` ); } @@ -289,16 +289,16 @@ export class TAPOCamera extends OnvifCamera { responseData?.data?.sec_left && responseData.data.sec_left > 0 ) { - this.log.debug("StokRefresh: Temporary Suspension (40404)", responseData); + this.log.debug("refreshStok: Temporary Suspension (40404)", responseData); throw new Error( - `StokRefresh: Temporary Suspension: Try again in ${responseData.data.sec_left} seconds` + `refreshStok: Temporary Suspension: Try again in ${responseData.data.sec_left} seconds` ); } if (responseData?.result?.stok) { this.stok = responseData.result.stok; - this.log.debug("StokRefresh: Success :>>", this.stok); + this.log.debug("refreshStok: Success :>>", this.stok); return this.stok!; }