Skip to content

Commit

Permalink
Adding naming accessory
Browse files Browse the repository at this point in the history
  • Loading branch information
kopiro committed Nov 26, 2023
1 parent 42bba16 commit 2155044
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ If you want to have manual control over the configuration, add the following con
streamPassword: "__STREAM_PASSWORD__", // This must be only alphanumeric [A-Za-z0-9], no special characters allowed!
streamUser: "__STREAM_USER__", // This must be only alphanumeric [A-Za-z0-9], no special characters allowed!

// Optionals, don't put them in the config if you need the default values
pullInterval: 60000, // Numbers of milliseconds after we update accessories by polling
disableStreaming: false, // Disables the video feed
disablePrivacyAccessory: false, // Disables the privacy accessory
disableAlarmAccessory: false, // Disables the alarm accessory
disableMotionAccessory: false, // Disables the motion detection sensor
lowQuality: false, // Video stream will be requested in low-quality (640x480) instead of HQ (1920x1080)

// An object containing a video-config passed to camera-ffmpeg
// Please check https://www.npmjs.com/package/homebridge-camera-ffmpeg for all the possible values\
// Make sure you don't override default values provided by this plugin unless you know what you're doing!
Expand Down
15 changes: 13 additions & 2 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"username": {
"title": "TAPO username",
"type": "string",
"required": false,
"description": "Most of the time you should leave this empty, defaulting to admin. If it doesn't work, try to use your streaming username (see below)"
},
"password": {
Expand Down Expand Up @@ -87,7 +86,19 @@
"title": "Low Quality",
"type": "boolean",
"description": "Video stream will be requested in low-quality (640x480) instead of HQ (1920x1080)"
}
},
"privacyAccessoryName": {
"title": "Privacy Accessory Name",
"type": "string",
"description": "Name of the Privacy accessory",
"placeholder": "Eyes"
},
"alarmAccessoryName": {
"title": "Alarm Accessory Name",
"type": "string",
"description": "Name of the Alarm accessory",
"placeholder": "Alarm"
},
}
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/cameraAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export type CameraConfig = {
lowQuality?: boolean;

videoConfig?: VideoConfig;

privacyAccessoryName?: string;
alarmAccessoryName?: string;
};

export class CameraAccessory {
Expand Down Expand Up @@ -81,8 +84,12 @@ export class CameraAccessory {
}

private setupAlarmAccessory() {
const name = `${this.config.name} - Alarm`;
const name = this.config.alarmAccessoryName || "Alarm";
this.alarmService = new this.api.hap.Service.Switch(name, "alarm");
this.alarmService.setCharacteristic(
this.api.hap.Characteristic.ConfiguredName,
name
);
this.alarmService = this.accessory.addService(this.alarmService);
this.alarmService
.getCharacteristic(this.api.hap.Characteristic.On)
Expand All @@ -108,8 +115,12 @@ export class CameraAccessory {
}

private setupPrivacyModeAccessory() {
const name = `${this.config.name} - Eyes`;
const name = this.config.privacyAccessoryName || "Eyes";
this.privacyService = new this.api.hap.Service.Switch(name, "privacy");
this.privacyService.setCharacteristic(
this.api.hap.Characteristic.ConfiguredName,
name
);
this.accessory.addService(this.privacyService);

this.privacyService
Expand Down

0 comments on commit 2155044

Please sign in to comment.