Skip to content

Commit

Permalink
Removing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kopiro committed Aug 27, 2024
1 parent 17f6e12 commit cef9987
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 70 deletions.
131 changes: 67 additions & 64 deletions src/cameraAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
12 changes: 6 additions & 6 deletions src/tapoCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -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`
);
}

Expand All @@ -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!;
}

Expand Down

0 comments on commit cef9987

Please sign in to comment.