Skip to content

Commit

Permalink
Merge branch 'main' of github.com:koush/scrypted
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Jul 12, 2024
2 parents fa9b4f1 + 855940f commit 3dcb36a
Show file tree
Hide file tree
Showing 30 changed files with 4,867 additions and 14 deletions.
7 changes: 4 additions & 3 deletions plugins/core/src/terminal-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class TerminalService extends ScryptedDeviceBase implements StreamService
* Resize: { "dim": { "cols": number, "rows": number } }
* EOF: { "eof": true }
*/
async connectStream(input: AsyncGenerator<Buffer | string, void>): Promise<AsyncGenerator<Buffer, void>> {
async connectStream(input: AsyncGenerator<Buffer | string, void>, options?: any): Promise<AsyncGenerator<Buffer, void>> {
let cp: InteractiveTerminal | NoninteractiveTerminal = null;
const queue = createAsyncQueue<Buffer>();

Expand Down Expand Up @@ -171,6 +171,7 @@ export class TerminalService extends ScryptedDeviceBase implements StreamService
} else if (parsed.eof) {
cp?.sendEOF();
} else if ("interactive" in parsed && !cp) {
const cmd = parsed.cmd || options?.cmd;
if (parsed.interactive) {
let spawn: typeof ptySpawn;
try {
Expand All @@ -182,15 +183,15 @@ export class TerminalService extends ScryptedDeviceBase implements StreamService
catch (e) {
spawn = require('@scrypted/node-pty').spawn as typeof ptySpawn;
}
cp = new InteractiveTerminal(parsed.cmd, spawn);
cp = new InteractiveTerminal(cmd, spawn);
}
catch (e) {
this.console.error('Error starting pty', e);
queue.end(e);
return;
}
} else {
cp = new NoninteractiveTerminal(parsed.cmd);
cp = new NoninteractiveTerminal(cmd);
}
registerChildListeners();
}
Expand Down
4 changes: 4 additions & 0 deletions plugins/hikvision-doorbell/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
out/
node_modules/
dist/
11 changes: 11 additions & 0 deletions plugins/hikvision-doorbell/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store
out/
node_modules/
*.map
fs
src
.vscode
dist/*.js
dist/*.txt
HAP-NodeJS
.gitmodules
23 changes: 23 additions & 0 deletions plugins/hikvision-doorbell/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Scrypted Debugger",
"address": "${config:scrypted.debugHost}",
"port": 10081,
"request": "attach",
"skipFiles": [
"**/plugin-remote-worker.*",
"<node_internals>/**"
],
"preLaunchTask": "scrypted: deploy+debug",
"sourceMaps": true,
"localRoot": "${workspaceFolder}/out",
"remoteRoot": "/plugin/",
"type": "node"
}
]
}
4 changes: 4 additions & 0 deletions plugins/hikvision-doorbell/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

{
"scrypted.debugHost": "127.0.0.1",
}
20 changes: 20 additions & 0 deletions plugins/hikvision-doorbell/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "scrypted: deploy+debug",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"command": "npm run scrypted-vscode-launch ${config:scrypted.debugHost}",
},
]
}
34 changes: 34 additions & 0 deletions plugins/hikvision-doorbell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Hikvision Doorbell Plugin for Scrypted (beta)

This plugin is based on [Hikvision Plugin for Scrypted](https://www.npmjs.com/package/@scrypted/hikvision), which is part of the [Scrypted](https://github.com/koush/scrypted) project.

The Hikvision Doorbell Plugin brings Hikvision-branded doorbells that are IP-based into Scrypted.
Most commonly this plugin is used with 2 plugins: Rebroadcast and HomeKit.

Device must have built-in motion detection (most Hikvision doorbells have this).
If the doorbell do not have motion detection, you will have to use a separate plugin or device to achieve this (e.g., `opencv`, `pam-diff`, or `dummy-switch`) and group it to the doorbell.

## Two Way Audio

Two Way Audio is supported if the audio codec is set to G.711ulaw on the doorbell, which is usually the default audio codec. This audio codec will also work with HomeKit. Changing the audio codec from G.711ulaw will cause Two Way Audio to fail on the doorbells that were tested.

## Codec Settings

Configure optimal codec settings (as required by HomeKit) through Hikvision's configuration webpage or device interface (not Scrypted).

Hikvision's [iVMS 4200 software](https://www.Hikvision.com/en/support/tools/), or similar, may be utilized to configure device as well as create a motion detection grid (required for motion detection and hardware dependent).

Generally, for newer devices the main stream (Stream 1) may be incompatible with HomeKit as it only outputs HEVC.
Configure and specify a substream instead (Stream 2 or 3).

The optimal/reliable codec settings can be found in the documentation for the [Homekit Plugin](https://github.com/koush/scrypted/tree/main/plugins/homekit).

# Troubleshooting

* Not receiving motion alerts in the device's Scrypted event log? Check all of the following: **(1)** device has a motion detection grid drawn and enabled, **(2)** user or group access permissions of account used for device **(3)** do not use self-signed certs for HTTPS on the device, **(4)** `CGI` and `ISAPI` integration protocol/service on device is enabled, and **(5)** that the authentication method on the device is set to "digest".
* If device has HTTPS enabled, try disabling HTTPS on the device to see if that resolves issue (do not use self-signed certs).
* If device has enabled user lockout, max connections, concurrent requests, etc., try disabling and/or increasing to max allowed for troubleshooting.
* Does your account (`Username`) have proper user and/or group permissions? Try granting all permissions for testing.
* Screenshots not working? Check that **(1)** `CGI` protocol is enabled in device settings (may be located at Network->Advanced Settings->Integration Protocol) and **(2)** lower Snapshot resolution with an `Override Snapshot URL` (above) to request a lower resolution snapshot (i.e. 720p or lower).
* Check that you have specified the correct `Default Stream` number in device (in Scrypted).
* Check that you have configured the correct Stream number's codec settings (in Hikvision's configuration page (Main Stream or Sub Stream(s)).
Loading

0 comments on commit 3dcb36a

Please sign in to comment.