Skip to content

Commit

Permalink
Merge pull request #164 from kopiro/video-options
Browse files Browse the repository at this point in the history
Add video options
  • Loading branch information
kopiro authored Oct 3, 2024
2 parents 5273452 + 83fb086 commit 6a542f3
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Make your TP-Link TAPO security camera compatible with Homekit through Homebridg

The plugin exposes the camera RTSP video feed, and toggle accessories to configure your automations.

If your video feed is not working, try to check if any of the parameters at the video config can be tuned. You can use [https://sunoo.github.io/homebridge-camera-ffmpeg/configs](https://sunoo.github.io/homebridge-camera-ffmpeg/configs) to check if someone has already found the right values for your camera.

> [!IMPORTANT]
> On firmware build 230921 and higher, [please follow this guide](https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/blob/main/add_camera_with_new_firmware.md) to make your camera compatible with this integration.
Expand Down
42 changes: 39 additions & 3 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"pluginAlias": "tapo-camera",
"pluginType": "platform",
"singular": true,
"headerDisplay": "Homebridge plugin for TP-Link TAPO security cameras",
"footerDisplay": null,
"headerDisplay": "Homebridge plugin for TP-Link TAPO security cameras.",
"footerDisplay": "If your video feed is not working, try to check if any of the parameters at the video config can be tuned. You can use https://sunoo.github.io/homebridge-camera-ffmpeg/configs to check if someone has already found the right values for your camera.",
"form": null,
"display": null,
"schema": {
Expand Down Expand Up @@ -100,7 +100,7 @@
"lowQuality": {
"title": "Low Quality",
"type": "boolean",
"description": "Video stream will be requested in low-quality (640x480) instead of HQ (1920x1080)"
"description": "Video stream will be requested in low-quality instead of high-quality"
},
"eyesToggleAccessoryName": {
"title": "Eyes (privacy mode) toggle Name",
Expand Down Expand Up @@ -131,6 +131,42 @@
"type": "string",
"description": "Name of the LED toggle",
"placeholder": "LED"
},

"videoMaxWidth": {
"title": "Video Max Width",
"type": "integer",
"description": "Maximum width of the video stream",
"placeholder": 1280
},
"videoMaxHeight": {
"title": "Video Max Height",
"type": "integer",
"description": "Maximum height of the video stream",
"placeholder": 720
},
"videoMaxFPS": {
"title": "Video Max FPS",
"type": "integer",
"description": "Maximum frames per second of the video stream",
"placeholder": 30
},
"videoMaxBitrate": {
"title": "Video Max Bitrate",
"type": "integer",
"description": "Maximum bitrate of the video stream",
"placeholder": 300
},
"videoPacketSize": {
"title": "Video Packet Size",
"type": "integer",
"description": "Size of the video packets",
"placeholder": 1316
},
"videoForceMax": {
"title": "Force Max Video",
"type": "boolean",
"description": "Force the video stream to use the maximum values, instead of the one provided by the Homekit request. Most likely you don't want this"
}
}
}
Expand Down
20 changes: 16 additions & 4 deletions src/cameraAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export type CameraConfig = {
disableMotionSensorAccessory?: boolean;
lowQuality?: boolean;

videoMaxWidth?: number;
videoMaxHeight?: number;
videoMaxFPS?: number;
videoForceMax?: boolean;
videoMaxBirate?: number;
videoPacketSize?: number;

videoConfig?: VideoConfig;

eyesToggleAccessoryName?: string;
Expand Down Expand Up @@ -168,12 +175,15 @@ export class CameraAccessory {
audio: true,
videoFilter: "none",
vcodec: "copy",
maxWidth: this.config.lowQuality ? 640 : 1920,
maxHeight: this.config.lowQuality ? 480 : 1080,
maxFPS: 15,
forceMax: true,
maxWidth: this.config.videoMaxWidth,
maxHeight: this.config.videoMaxHeight,
maxFPS: this.config.videoMaxFPS,
maxBitrate: this.config.videoMaxBirate,
packetSize: this.config.videoPacketSize,
forceMax: this.config.videoForceMax,
...(this.config.videoConfig || {}),
};

return config;
}

Expand All @@ -195,6 +205,8 @@ export class CameraAccessory {
);

this.accessory.configureController(delegate.controller);

this.log.debug("Camera streaming setup done");
} catch (err) {
this.log.error("Error setting up camera streaming:", err);
}
Expand Down
18 changes: 18 additions & 0 deletions src/types/tapo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ export type TAPOCameraGetRequest =
name: "config";
};
};
}
| {
method: "getWhitelampStatus";
params: {
image: {
get_wtl_status: "null";
};
};
};

export type TAPOCameraSetRequest =
Expand Down Expand Up @@ -102,6 +110,16 @@ export type TAPOCameraSetRequest =
};
};
};
}
| {
method: "setWhitelampConfig";
params: {
image: {
switch: {
wtl_intensity_level: string;
};
};
};
};

export type TAPOCameraUnencryptedRequest = {
Expand Down

0 comments on commit 6a542f3

Please sign in to comment.