diff --git a/.github/workflows/publish-beta.yml b/.github/workflows/publish-beta.yml index 76d58d1..7a250bf 100644 --- a/.github/workflows/publish-beta.yml +++ b/.github/workflows/publish-beta.yml @@ -28,7 +28,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.2 + - uses: actions/checkout@v2.3.1 + with: + ref: beta - uses: actions/setup-node@v2.1.1 with: node-version: 10 diff --git a/README.md b/README.md index e922459..49abe18 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,7 @@ Edit your `config.json` accordingly. Configuration sample: - `motorsHorizontal`: Exposes panning left and right as switches. - `recording`: Exposes video recording as a switch. - `snapshot`: Exposes snapshot as a switch. + - `rtsp_mjpeg_server`: Exposes RTSP MJPEG server as a switch. + - `rtsp_h264_server`: Exposes RTSP H264 server as a switch. + - `remount_sdcard`: Exposes remounting SD card as a switch. + - `reboot`: Exposes rebotting as a switch. diff --git a/config.schema.json b/config.schema.json index 8888231..733a735 100644 --- a/config.schema.json +++ b/config.schema.json @@ -132,6 +132,22 @@ { "title": "Hardware", "enum": ["hw"] }, { "title": "Virtual", "enum": ["virtual"] } ] + }, + "rtsp_mjpeg_server": { + "title": "RTSP MJPEG Server", + "type": "boolean" + }, + "rtsp_h264_server": { + "title": "RTSP H264 Server", + "type": "boolean" + }, + "remount_sdcard": { + "title": "Remount SD Card", + "type": "boolean" + }, + "reboot": { + "title": "Reboot", + "type": "boolean" } } } diff --git a/package-lock.json b/package-lock.json index 116a82b..1d6244c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-dafang-mqtt-republish", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -62,18 +62,18 @@ "dev": true }, "@types/node": { - "version": "14.0.25", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.25.tgz", - "integrity": "sha512-okMqUHqrMlGOxfDZliX1yFX5MV6qcd5PpRz96XYtjkM0Ws/hwg23FMUqt6pETrVRZS+EKUB5HY19mmo54EuQbA==", + "version": "14.6.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz", + "integrity": "sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==", "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.0.tgz", - "integrity": "sha512-4OEcPON3QIx0ntsuiuFP/TkldmBGXf0uKxPQlGtS/W2F3ndYm8Vgdpj/woPJkzUc65gd3iR+qi3K8SDQP/obFg==", + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.9.1.tgz", + "integrity": "sha512-XIr+Mfv7i4paEdBf0JFdIl9/tVxyj+rlilWIfZ97Be0lZ7hPvUbS5iHt9Glc8kRI53dsr0PcAEudbf8rO2wGgg==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "3.7.0", + "@typescript-eslint/experimental-utils": "3.9.1", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -82,45 +82,45 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.0.tgz", - "integrity": "sha512-xpfXXAfZqhhqs5RPQBfAFrWDHoNxD5+sVB5A46TF58Bq1hRfVROrWHcQHHUM9aCBdy9+cwATcvCbRg8aIRbaHQ==", + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.9.1.tgz", + "integrity": "sha512-lkiZ8iBBaYoyEKhCkkw4SAeatXyBq9Ece5bZXdLe1LWBUwTszGbmbiqmQbwWA8cSYDnjWXp9eDbXpf9Sn0hLAg==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/typescript-estree": "3.7.0", + "@typescript-eslint/types": "3.9.1", + "@typescript-eslint/typescript-estree": "3.9.1", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.0.tgz", - "integrity": "sha512-2LZauVUt7jAWkcIW7djUc3kyW+fSarNEuM3RF2JdLHR9BfX/nDEnyA4/uWz0wseoWVZbDXDF7iF9Jc342flNqQ==", + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.9.1.tgz", + "integrity": "sha512-y5QvPFUn4Vl4qM40lI+pNWhTcOWtpZAJ8pOEQ21fTTW4xTJkRplMjMRje7LYTXqVKKX9GJhcyweMz2+W1J5bMg==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "3.7.0", - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/typescript-estree": "3.7.0", + "@typescript-eslint/experimental-utils": "3.9.1", + "@typescript-eslint/types": "3.9.1", + "@typescript-eslint/typescript-estree": "3.9.1", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/types": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.0.tgz", - "integrity": "sha512-reCaK+hyKkKF+itoylAnLzFeNYAEktB0XVfSQvf0gcVgpz1l49Lt6Vo9x4MVCCxiDydA0iLAjTF/ODH0pbfnpg==", + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.9.1.tgz", + "integrity": "sha512-15JcTlNQE1BsYy5NBhctnEhEoctjXOjOK+Q+rk8ugC+WXU9rAcS2BYhoh6X4rOaXJEpIYDl+p7ix+A5U0BqPTw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.0.tgz", - "integrity": "sha512-xr5oobkYRebejlACGr1TJ0Z/r0a2/HUf0SXqPvlgUMwiMqOCu/J+/Dr9U3T0IxpE5oLFSkqMx1FE/dKaZ8KsOQ==", + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.9.1.tgz", + "integrity": "sha512-IqM0gfGxOmIKPhiHW/iyAEXwSVqMmR2wJ9uXHNdFpqVvPaQ3dWg302vW127sBpAiqM9SfHhyS40NKLsoMpN2KA==", "dev": true, "requires": { - "@typescript-eslint/types": "3.7.0", - "@typescript-eslint/visitor-keys": "3.7.0", + "@typescript-eslint/types": "3.9.1", + "@typescript-eslint/visitor-keys": "3.9.1", "debug": "^4.1.1", "glob": "^7.1.6", "is-glob": "^4.0.1", @@ -141,18 +141,18 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.0.tgz", - "integrity": "sha512-k5PiZdB4vklUpUX4NBncn5RBKty8G3ihTY+hqJsCdMuD0v4jofI5xuqwnVcWxfv6iTm2P/dfEa2wMUnsUY8ODw==", + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.9.1.tgz", + "integrity": "sha512-zxdtUjeoSh+prCpogswMwVUJfEFmCOjdzK9rpNjNBfm6EyPt99x3RrJoBOGZO23FCt0WPKUCOL5mb/9D5LjdwQ==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" } }, "acorn": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", - "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", + "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true }, "acorn-jsx": { @@ -162,9 +162,9 @@ "dev": true }, "ajv": { - "version": "6.12.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz", - "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==", + "version": "6.12.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", + "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -221,11 +221,6 @@ "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, - "async-limiter": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", - "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" - }, "available-typed-arrays": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz", @@ -668,9 +663,9 @@ "dev": true }, "eslint": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.5.0.tgz", - "integrity": "sha512-vlUP10xse9sWt9SGRtcr1LAC67BENcQMFeV+w5EvLEoFe3xJ8cF1Skd0msziRx/VMC+72B4DxreCE+OR12OA6Q==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.7.0.tgz", + "integrity": "sha512-1KUxLzos0ZVsyL81PnRN335nDtQ8/vZUD6uMtWbF+5zDtjKcsklIi78XoE0MVL93QvWTu+E5y44VyyCsOMBrIg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -783,9 +778,9 @@ }, "dependencies": { "estraverse": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.1.0.tgz", - "integrity": "sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", "dev": true } } @@ -1039,9 +1034,9 @@ } }, "homebridge": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.1.1.tgz", - "integrity": "sha512-eOmHjRSkmkCD3iUqQKAo1fcSFs8gZCAW4LVjBYpxH6mEgKQlYxh9tUtgEIzny6bkplYmOOahQPHSjzfNTDjr6w==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/homebridge/-/homebridge-1.1.2.tgz", + "integrity": "sha512-Ckcdh5wfarCODV4jr1APHYHS5CDl8cCvLXco01rcoEAx6ytjufSlmX6kyo7mtQGMoF8vaKyBy5K1FBwVi+C46A==", "dev": true, "requires": { "chalk": "^4.1.0", @@ -1177,9 +1172,9 @@ "dev": true }, "is-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", - "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz", + "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==", "dev": true, "requires": { "has-symbols": "^1.0.1" @@ -1443,9 +1438,9 @@ } }, "mqtt": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.1.0.tgz", - "integrity": "sha512-dBihVZzaB8p9G/2ktSfamiaHmMnpCpP2du08317ZuEX1kBAbZOG9aMJQ11EChXnOX3GKUeiZYaSITueceQKT2A==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-4.2.0.tgz", + "integrity": "sha512-CGMLigAKCp0hknWPM15yuZRbVrfQjZCG9Wn3GXDEfY2chDmUi5GT3UQ3OhTtMi7fELYb2s4Q/QiWv+dECQ7ZQg==", "requires": { "base64-js": "^1.3.0", "commist": "^1.0.0", @@ -1455,13 +1450,13 @@ "es6-map": "^0.1.5", "help-me": "^1.0.1", "inherits": "^2.0.3", - "minimist": "^1.2.0", - "mqtt-packet": "^6.0.0", + "minimist": "^1.2.5", + "mqtt-packet": "^6.3.2", "pump": "^3.0.0", "readable-stream": "^2.3.6", "reinterval": "^1.1.0", "split2": "^3.1.0", - "websocket-stream": "^5.1.2", + "ws": "^7.3.1", "xtend": "^4.0.1" } }, @@ -2026,9 +2021,9 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "typescript": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", - "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz", + "integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==", "dev": true }, "uc.micro": { @@ -2037,11 +2032,6 @@ "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", "dev": true }, - "ultron": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", - "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" - }, "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", @@ -2076,19 +2066,6 @@ "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==", "dev": true }, - "websocket-stream": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/websocket-stream/-/websocket-stream-5.5.2.tgz", - "integrity": "sha512-8z49MKIHbGk3C4HtuHWDtYX8mYej1wWabjthC/RupM9ngeukU4IWoM46dgth1UOS/T4/IqgEdCDJuMe2039OQQ==", - "requires": { - "duplexify": "^3.5.1", - "inherits": "^2.0.1", - "readable-stream": "^2.3.3", - "safe-buffer": "^5.1.2", - "ws": "^3.2.0", - "xtend": "^4.0.0" - } - }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -2158,14 +2135,9 @@ } }, "ws": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", - "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", - "requires": { - "async-limiter": "~1.0.0", - "safe-buffer": "~5.1.0", - "ultron": "~1.1.0" - } + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" }, "xtend": { "version": "4.0.2", diff --git a/package.json b/package.json index 89282e2..d5f8c4a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Homebridge Dafang MQTT Republish", "name": "homebridge-dafang-mqtt-republish", - "version": "2.1.0", + "version": "2.1.1", "description": "Routes Dafang Hacks Motion Messages to homebridge-camera-ffmpeg and Exposes Features to HomeKit", "main": "dist/index.js", "repository": { @@ -35,13 +35,20 @@ "devDependencies": { "@typescript-eslint/eslint-plugin": "^3.7.0", "@typescript-eslint/parser": "^3.7.0", - "@types/node": "14.0.25", + "@types/node": "14.6.0", "eslint": "^7.5.0", "homebridge": "^1.1.1", "markdownlint-cli": "^0.23.2", "rimraf": "^3.0.2", - "typescript": "^3.9.7" + "typescript": "^4.0.2" }, + "files": [ + "config.schema.json", + "dist/**/*", + "LICENSE", + "package.json", + "README.md" + ], "engines": { "node": ">=10", "homebridge": ">=1.0.0" diff --git a/src/configTypes.ts b/src/configTypes.ts index 939e490..e47f835 100644 --- a/src/configTypes.ts +++ b/src/configTypes.ts @@ -29,4 +29,8 @@ export type AccessoriesConfig = { recording: boolean; snapshot: boolean; brightness: string; + rtsp_mjpeg_server: boolean; + rtsp_h264_server: boolean; + remount_sdcard: boolean; + reboot: boolean; }; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index bf9904c..f551d9e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -138,6 +138,10 @@ class DafangMqttPlatform implements DynamicPlatformPlugin { let motorsRightService = accessory.getServiceById(hap.Service.Switch, '/motors/horizontal/right'); let recordingService = accessory.getServiceById(hap.Service.Switch, '/recording'); let snapshotService = accessory.getServiceById(hap.Service.Switch, '/snapshot'); + let rtspMjpegService = accessory.getServiceById(hap.Service.Switch, '/rtsp_mjpeg_server'); + let rtspH264Service = accessory.getServiceById(hap.Service.Switch, '/rtsp_h264_server'); + let remountService = accessory.getServiceById(hap.Service.Switch, '/remount_sdcard'); + let rebootService = accessory.getServiceById(hap.Service.Switch, '/reboot'); if (blueLedService) { accessory.removeService(blueLedService); @@ -178,6 +182,18 @@ class DafangMqttPlatform implements DynamicPlatformPlugin { if (snapshotService) { accessory.removeService(snapshotService); } + if (rtspMjpegService) { + accessory.removeService(rtspMjpegService); + } + if (rtspH264Service) { + accessory.removeService(rtspH264Service); + } + if (remountService) { + accessory.removeService(remountService); + } + if (rebootService) { + accessory.removeService(rebootService); + } if (config.accessories.blueLed) { blueLedService = new hap.Service.Lightbulb(config.name + ' Blue LED', '/leds/blue'); @@ -339,6 +355,62 @@ class DafangMqttPlatform implements DynamicPlatformPlugin { }); accessory.addService(snapshotService); } + if (config.accessories.rtsp_mjpeg_server) { + rtspMjpegService = new hap.Service.Switch(config.name + ' RTSP MJPEG Server', '/rtsp_mjpeg_server'); + rtspMjpegService.getCharacteristic(hap.Characteristic.On) + .on('set', (value: CharacteristicValue, callback: CharacteristicSetCallback) => { + const message = value ? 'ON' : 'OFF'; + this.publishMqtt(config.dafang_topic + '/rtsp_mjpeg_server/set', message); + callback(); + }); + accessory.addService(rtspMjpegService); + } + if (config.accessories.rtsp_h264_server) { + rtspH264Service = new hap.Service.Switch(config.name + ' RTSP H264 Server', '/rtsp_h264_server'); + rtspH264Service.getCharacteristic(hap.Characteristic.On) + .on('set', (value: CharacteristicValue, callback: CharacteristicSetCallback) => { + const message = value ? 'ON' : 'OFF'; + this.publishMqtt(config.dafang_topic + '/rtsp_h264_server/set', message); + callback(); + }); + accessory.addService(rtspH264Service); + } + if (config.accessories.remount_sdcard) { + remountService = new hap.Service.Switch(config.name + ' Remount SD Card', '/remount_sdcard'); + remountService.getCharacteristic(hap.Characteristic.On) + .on('set', (value: CharacteristicValue, callback: CharacteristicSetCallback) => { + if (value) { + this.publishMqtt(config.dafang_topic + '/remount_sdcard/set', 'ON'); + if (value) { + setTimeout(() => { + if (remountService) { + remountService.updateCharacteristic(hap.Characteristic.On, false); + } + }, 1000); + } + } + callback(); + }); + accessory.addService(remountService); + } + if (config.accessories.reboot) { + rebootService = new hap.Service.Switch(config.name + ' Reboot', '/reboot'); + rebootService.getCharacteristic(hap.Characteristic.On) + .on('set', (value: CharacteristicValue, callback: CharacteristicSetCallback) => { + if (value) { + this.publishMqtt(config.dafang_topic + '/reboot/set', 'ON'); + if (value) { + setTimeout(() => { + if (rebootService) { + rebootService.updateCharacteristic(hap.Characteristic.On, false); + } + }, 1000); + } + } + callback(); + }); + accessory.addService(rebootService); + } this.accessories.push(accessory); } @@ -504,6 +576,18 @@ class DafangMqttPlatform implements DynamicPlatformPlugin { case '/recording': this.handleBoolService(accessory, hap.Service.Switch, '/recording', msg); break; + case '/rtsp_mjpeg_server': + this.handleBoolService(accessory, hap.Service.Switch, '/rtsp_mjpeg_server', msg); + break; + case '/rtsp_h264_server': + this.handleBoolService(accessory, hap.Service.Switch, '/rtsp_h264_server', msg); + break; + case '/remount_sdcard': + this.handleBoolService(accessory, hap.Service.Switch, '/remount_sdcard', msg); + break; + case '/reboot': + this.handleBoolService(accessory, hap.Service.Switch, '/reboot', msg); + break; } } });