Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using encrypted traffic #94

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ node_modules/
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.cache

.env
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
21 changes: 19 additions & 2 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@
"description": "Set the camera IP address",
"placeholder": "192.168.0.XXX"
},
"username": {
"title": "TAPO username",
"type": "string",
"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": {
"title": "TAPO password",
"type": "string",
"required": true,
"description": "Password of your TAPO app (not the password for the RTSP configuration)"
"description": "Password of your TAPO Cloud (the one you use to login the application, not the password for the RTSP configuration). If it doesn't work, try to use your streaming password (see below)"
},
"streamUser": {
"title": "Stream User",
Expand Down Expand Up @@ -81,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
35 changes: 27 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"url": "https://www.paypal.me/kopiro"
},
"dependencies": {
"dotenv": "^16.3.1",
"homebridge-camera-ffmpeg": "^3.1.4",
"node-fetch": "^2.6.7",
"onvif": "^0.6.6"
Expand All @@ -56,7 +57,7 @@
"homebridge": "^1.3.5",
"nodemon": "^2.0.15",
"rimraf": "^3.0.2",
"ts-node": "^10.5.0",
"ts-node": "^10.9.1",
"typescript": "^4.4.3"
}
}
34 changes: 21 additions & 13 deletions src/cameraAccessory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
API,
Characteristic,

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (12.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (12.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (13.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (13.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (15.x)

'Characteristic' is defined but never used

Check warning on line 3 in src/cameraAccessory.ts

View workflow job for this annotation

GitHub Actions / build (15.x)

'Characteristic' is defined but never used
Logging,
PlatformAccessory,
PlatformAccessoryEvent,
Expand All @@ -9,13 +10,14 @@
import { Logger } from "homebridge-camera-ffmpeg/dist/logger";
import { TAPOCamera } from "./tapoCamera";
import { PLUGIN_ID } from "./pkg";
import { DeviceInformation } from "onvif";
import { DeviceInformation } from "./types/onvif";
import { CameraPlatform } from "./cameraPlatform";
import { VideoConfig } from "homebridge-camera-ffmpeg/dist/configTypes";

export type CameraConfig = {
name: string;
ipAddress: string;
username: string;
password: string;
streamUser: string;
streamPassword: string;
Expand All @@ -28,6 +30,9 @@
lowQuality?: boolean;

videoConfig?: VideoConfig;

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

export class CameraAccessory {
Expand Down Expand Up @@ -79,12 +84,13 @@
}

private setupAlarmAccessory() {
const name = `${this.config.name} - Alarm`;
this.alarmService = this.accessory.addService(
this.api.hap.Service.Switch,
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)
.onGet(() => {
Expand All @@ -96,7 +102,7 @@
return this.cameraStatus.alert;
})
.onSet((status) => {
this.log.debug(`Setting alarm to ${status ? "on" : "off"}`);
this.log.info(`Setting alarm to ${status ? "on" : "off"}`);
this.camera.setAlertConfig(Boolean(status)).catch((err) => {
this.log.error(
`[${this.config.name}]`,
Expand All @@ -109,12 +115,14 @@
}

private setupPrivacyModeAccessory() {
const name = `${this.config.name} - Eyes`;
this.privacyService = this.accessory.addService(
this.api.hap.Service.Switch,
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
.getCharacteristic(this.api.hap.Characteristic.On)
.onGet(async () => {
Expand All @@ -126,7 +134,7 @@
return !this.cameraStatus.lensMask;
})
.onSet((status) => {
this.log.debug(`Setting privacy to ${status ? "on" : "off"}`);
this.log.info(`Setting privacy to ${status ? "on" : "off"}`);
this.camera.setLensMaskConfig(!status).catch((err) => {
this.log.error(
`[${this.config.name}]`,
Expand Down
Loading
Loading