From e796724c248341a14137f239acbc594a2d4330e3 Mon Sep 17 00:00:00 2001 From: Dov Benyomin Sohacheski Date: Wed, 30 Aug 2023 05:54:05 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A7=B9=20Install=20`pre-commit`=20and?= =?UTF-8?q?=20fixes=20lint=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 2 +- .flake8 | 2 +- .github/ISSUE_TEMPLATE/bug_report.yml | 14 ++--- .github/ISSUE_TEMPLATE/feature_request.yml | 8 +-- .github/workflows/docs.yml | 4 +- .github/workflows/image.yml | 2 +- .markdownlint.yaml | 8 +++ .pre-commit-config.yaml | 38 ++++++++++++ README.md | 7 ++- docker-compose.yml => docker-compose.yaml | 0 docs/README.md | 36 +++++------ docs/docs/configuration/_category_.json | 3 +- docs/docs/configuration/amcrest.md | 23 ++++--- docs/docs/configuration/dahua.md | 12 ++-- docs/docs/configuration/frigate.md | 15 ++--- docs/docs/configuration/hikvision.md | 20 +++--- docs/docs/configuration/reolink.md | 19 +++--- docs/docs/configuration/reolink_nvr.md | 13 ++-- docs/docs/configuration/rtsp.md | 11 ++-- docs/docs/intro.md | 71 +++++++++++++++------- docs/package.json | 2 +- docs/src/pages/markdown-page.md | 7 --- docs/static/img/logo.svg | 2 +- docs/static/img/undraw_docusaurus_tree.svg | 2 +- unifi/cams/frigate.py | 2 +- 26 files changed, 200 insertions(+), 125 deletions(-) create mode 100644 .markdownlint.yaml create mode 100644 .pre-commit-config.yaml rename docker-compose.yml => docker-compose.yaml (100%) delete mode 100644 docs/src/pages/markdown-page.md diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index eeb2fbf..b088f0e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,4 +5,4 @@ WORKDIR /app RUN apt-get update && apt-get install -y ffmpeg netcat-openbsd COPY . . -RUN pip install . \ No newline at end of file +RUN pip install . diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 461b096..5022fad 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,7 +27,7 @@ "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" }, - + // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-python.python", diff --git a/.flake8 b/.flake8 index b345d99..32aae51 100644 --- a/.flake8 +++ b/.flake8 @@ -2,4 +2,4 @@ max-line-length = 88 select = C,E,F,W,B,B950 ignore = E203,E501,W503 -exclude = .git,__pycache__,venv,build,dist \ No newline at end of file +exclude = .git,__pycache__,venv,build,dist diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 5aa4689..9b49da2 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,6 +1,6 @@ name: Bug report description: Create a bug report to help us improve -labels: +labels: - "Type: Bug" - "Status: Waiting triage" body: @@ -9,11 +9,11 @@ body: value: | # :warning: **Please read before raising the issue** :warning: - If you have a **question**, need clarification on something, need help on a particular situation or want to start a discussion, **DO NOT** open an issue here. _It will be automatically closed!_ - - Ask the question on one of our [Discord channels](https://discord.gg/Bxk9uGT6MW) + If you have a **question**, need clarification on something, need help on a particular situation or want to start a discussion, **DO NOT** open an issue here. _It will be automatically closed!_ + + Ask the question on one of our [Discord channels](https://discord.gg/Bxk9uGT6MW) If you're not keen to Discord, you can also use [GitHub Discussions](https://github.com/keshavdv/unifi-cam-proxy/discussions). - If you realy want to raise an issue, please make sure to follow the template and provide the required information. Failing to do so will most likely end up on the issue being close. Don't take offense at this. It is simply a time management decision. Whenever an issue is raised without following the template and the required information is not provided, very often too much time has to be spent going back and forth to obtain the details that are outlined below. + If you really want to raise an issue, please make sure to follow the template and provide the required information. Failing to do so will most likely end up on the issue being close. Don't take offense at this. It is simply a time management decision. Whenever an issue is raised without following the template and the required information is not provided, very often too much time has to be spent going back and forth to obtain the details that are outlined below. - type: input id: camera_model @@ -73,7 +73,7 @@ body: - type: textarea id: other_things attributes: - label: Aditional information + label: Additional information description: Other suggested things. If applicable/relevant. placeholder: | for example link to the repository with sample code @@ -85,5 +85,5 @@ body: attributes: value: | ### Make an effort to fix the bug - + Attempt to submit a [Pull Request (PR)](https://help.github.com/articles/about-pull-requests/) that fixes the bug. Include in this PR a test that verifies the fix. If you were not able to fix the bug, a PR that illustrates your partial progress will suffice. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index df25879..eeb069a 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,6 +1,6 @@ name: Feature request description: Suggest an idea to help us improve. -labels: +labels: - "Type: Feature request" - "Status: waiting feedback" body: @@ -9,12 +9,12 @@ body: value: | # :warning: **Please read before raising the issue** :warning: - If you have a **question**, need clarification on something, need help on a particular situation or want to start a discussion, **DO NOT** open an issue here. _It will be automatically closed!_ - + If you have a **question**, need clarification on something, need help on a particular situation or want to start a discussion, **DO NOT** open an issue here. _It will be automatically closed!_ + Ask the question on one of our [Discord channels](https://discord.gg/Bxk9uGT6MW). If you're not keen to Discord, you can also use [GitHub Discussions](https://github.com/keshavdv/unifi-cam-proxy/discussions). - If you realy want to raise an issue, please make sure to follow the template and provide the required information. Failing to do so will most likely end up on the issue being close. Don't take offense at this. It is simply a time management decision. Whenever an issue is raised without following the template and the required information is not provided, very often too much time has to be spent going back and forth to obtain the details that are outlined below. + If you really want to raise an issue, please make sure to follow the template and provide the required information. Failing to do so will most likely end up on the issue being close. Don't take offense at this. It is simply a time management decision. Whenever an issue is raised without following the template and the required information is not provided, very often too much time has to be spent going back and forth to obtain the details that are outlined below. - type: textarea id: description diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 90e55ac..2cc40c5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,14 +15,14 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - + - name: 🔵 Setup NodeJS uses: actions/setup-node@v3 with: node-version: 16 cache: yarn cache-dependency-path: ./docs/yarn.lock - + - name: ⏬ Install Dependencies run: yarn install --frozen-lockfile working-directory: docs diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 2f891ab..c7d659a 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -42,7 +42,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..e9e882d --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,8 @@ +default: true + +# line-length +MD013: + line_length: 100 + code_block_line_length: 120 + +MD041: false \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b087fb1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,38 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + args: + - --markdown-linebreak-ext=md + + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + + - repo: https://github.com/codespell-project/codespell + rev: v2.2.5 + hooks: + - id: codespell + args: + - --skip=docs/yarn.lock + + - repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black + + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.35.0 + hooks: + - id: markdownlint-fix + + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 + hooks: + - id: flake8 diff --git a/README.md b/README.md index 20d3c9d..d752911 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![unifi-cam-proxy Discord](https://img.shields.io/discord/937237037466124330?color=0559C9&label=Discord&logo=discord&logoColor=%23FFFFFF&style=for-the-badge)](https://discord.gg/Bxk9uGT6MW) -UniFi Camera Proxy -================== +# UniFi Camera Proxy + ## About This enables using non-Ubiquiti cameras within the UniFi Protect ecosystem. This is @@ -9,6 +9,7 @@ particularly useful to use existing RTSP-enabled cameras in the same UI and mobile app as your other Unifi devices. Things that work: + * Live streaming * Full-time recording * Motion detection with certain cameras @@ -16,7 +17,7 @@ Things that work: ## Documentation -View the documentation at https://unifi-cam-proxy.com +View the documentation at ## Donations diff --git a/docker-compose.yml b/docker-compose.yaml similarity index 100% rename from docker-compose.yml rename to docker-compose.yaml diff --git a/docs/README.md b/docs/README.md index aaba2fa..af5f51e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,40 +2,42 @@ This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. -### Installation +## Installation -``` -$ yarn +```sh +yarn ``` -### Local Development +## Local Development -``` -$ yarn start +```sh +yarn start ``` -This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. +This command starts a local development server and opens up a browser window. +Most changes are reflected live without having to restart the server. -### Build +## Build -``` -$ yarn build +```sh +yarn build ``` -This command generates static content into the `build` directory and can be served using any static contents hosting service. +This command generates static content in the `build` directory. +It can then be served using any static content hosting service. -### Deployment +## Deployment Using SSH: -``` -$ USE_SSH=true yarn deploy +```sh +USE_SSH=true yarn deploy ``` Not using SSH: -``` -$ GIT_USER= yarn deploy +```sh +GIT_USER= yarn deploy ``` -If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. +If you're using GitHub pages, this command is a convenient way to build and push to the `gh-pages` branch. diff --git a/docs/docs/configuration/_category_.json b/docs/docs/configuration/_category_.json index 96b4a1a..50926b2 100644 --- a/docs/docs/configuration/_category_.json +++ b/docs/docs/configuration/_category_.json @@ -1,5 +1,4 @@ { "label": "Camera-Specific Configuration", "position": 1 - } - \ No newline at end of file +} diff --git a/docs/docs/configuration/amcrest.md b/docs/docs/configuration/amcrest.md index 1f5211d..2ce6a83 100644 --- a/docs/docs/configuration/amcrest.md +++ b/docs/docs/configuration/amcrest.md @@ -4,8 +4,9 @@ sidebar_position: 3 # Amcrest -### Options -``` +## Options + +```text optional arguments: --ffmpeg-args FFMPEG_ARGS, -f FFMPEG_ARGS Transcoding args for `ffmpeg -i ` @@ -27,20 +28,22 @@ optional arguments: VideoMotion event index ``` -### Amcrest IP8M-T2599E +## Amcrest IP8M-T2599E - [x] Supports full time recording - [x] Supports motion events - [ ] Supports smart detection - Notes: - * Camera configuration: - * Video codec must be H.264 (H.265/HEVC is not supported). - * Audio codec should be AAC. If not, adjust the ffmpeg args to re-encode to AAC. - * Ensure the sub stream is enabled. - * If desired, ensure motion detection is enabled with the desired anti-dither and detection area. - * The `-bsf:v` parameter is needed to make live video work. The first `tick_rate` value should be `fps * 2000`. See [this comment](https://github.com/keshavdv/unifi-cam-proxy/issues/31#issuecomment-841914363). + - Camera configuration: + - Video codec must be H.264 (H.265/HEVC is not supported). + - Audio codec should be AAC. If not, adjust the ffmpeg args to re-encode to AAC. + - Ensure the sub stream is enabled. + - If desired, ensure motion detection is enabled with the desired anti-dither and detection area. + - The `-bsf:v` parameter is needed to make live video work. + The first `tick_rate` value should be `fps * 2000`. + See [this comment](https://github.com/keshavdv/unifi-cam-proxy/issues/31#issuecomment-841914363). -``` +```sh unifi-cam-proxy --mac '{unique MAC}' -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} \ amcrest \ -u {username} \ diff --git a/docs/docs/configuration/dahua.md b/docs/docs/configuration/dahua.md index 53c3af7..134db75 100644 --- a/docs/docs/configuration/dahua.md +++ b/docs/docs/configuration/dahua.md @@ -4,8 +4,9 @@ sidebar_position: 3 # Dahua/Lorex -### Options -``` +## Options + +```text optional arguments: --ffmpeg-args FFMPEG_ARGS, -f FFMPEG_ARGS Transcoding args for `ffmpeg -i ` @@ -27,14 +28,13 @@ optional arguments: VideoMotion event index ``` - -### Lorex LNB4321B - +## Lorex LNB4321B - [x] Supports full time recording - [x] Supports motion events - [ ] Supports smart detection -``` + +```sh unifi-cam-proxy --mac '{unique MAC}' -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} \ dahua \ -u {username} \ diff --git a/docs/docs/configuration/frigate.md b/docs/docs/configuration/frigate.md index f6cd8fb..5061117 100644 --- a/docs/docs/configuration/frigate.md +++ b/docs/docs/configuration/frigate.md @@ -4,25 +4,23 @@ sidebar_position: 2 # Frigate - If your camera model is not listed specifically below, try the following: - [x] Supports full time recording - [ ] Supports motion events - [x] Supports smart detection - -``` +```sh unifi-cam-proxy --mac '{unique MAC}' -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} \ - frigate \ - -s {rtsp source} \ - --mqtt-host {mqtt host} \ - --frigate-camera {Name of camera in frigate} + frigate \ + -s {rtsp source} \ + --mqtt-host {mqtt host} \ + --frigate-camera {Name of camera in frigate} ``` ## Options -``` +```text optional arguments: --ffmpeg-args FFMPEG_ARGS, -f FFMPEG_ARGS Transcoding args for `ffmpeg -i ` @@ -42,4 +40,3 @@ optional arguments: --frigate-camera FRIGATE_CAMERA Name of camera in frigate ``` - diff --git a/docs/docs/configuration/hikvision.md b/docs/docs/configuration/hikvision.md index 9bc6f7c..757665f 100644 --- a/docs/docs/configuration/hikvision.md +++ b/docs/docs/configuration/hikvision.md @@ -4,15 +4,17 @@ sidebar_position: 3 # Hikvision -### Generic +## Generic + If your camera model is not listed specifically below, try the following: -``` +```sh unifi-cam-proxy -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} hikvision -u {username} -p {password} ``` -### Options -``` +## Options + +```text optional arguments: --ffmpeg-args FFMPEG_ARGS, -f FFMPEG_ARGS Transcoding args for `ffmpeg -i ` @@ -24,13 +26,15 @@ optional arguments: Camera password ``` +## Hikvision DS-2DE3304W-DE -### Hikvision DS-2DE3304W-DE - [x] Supports full time recording - [ ] Supports motion events - [ ] Supports smart detection - Notes: - * Change Pan/Tilt/Zoom via brightness/saturation/hue camera setting -``` -unifi-cam-proxy --mac '{unique MAC}' -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} hikvision -u {username} -p {password} + - Change Pan/Tilt/Zoom via brightness/saturation/hue camera setting + +```sh +unifi-cam-proxy --mac '{unique MAC}' -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} \ + hikvision -u {username} -p {password} ``` diff --git a/docs/docs/configuration/reolink.md b/docs/docs/configuration/reolink.md index a8c5acc..aee1959 100644 --- a/docs/docs/configuration/reolink.md +++ b/docs/docs/configuration/reolink.md @@ -4,10 +4,11 @@ sidebar_position: 4 # Reolink -### Generic +## Generic + If your camera model is not listed specifically below, try the following: -``` +```sh unifi-cam-proxy -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} \ reolink \ -u {username} \ @@ -16,8 +17,9 @@ unifi-cam-proxy -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} \ --ffmpeg-args='-c:v copy -bsf:v "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k' ``` -### Options -``` +## Options + +```text optional arguments: -h, --help show this help message and exit --ffmpeg-args FFMPEG_ARGS, -f FFMPEG_ARGS @@ -30,16 +32,17 @@ optional arguments: Camera password --substream SUBSTREAM, -s CHANNEL Camera rtsp url substream index main, or sub -``` +``` + +## RLC-410-5MP -### RLC-410-5MP - [x] Supports full time recording - [x] Supports motion events - [ ] Supports smart detection - Notes: - * When using the 'sub' substream, use `tick_rate=30000/1001` because the stream is limited to a maximum of 15fps + - When using 'sub' substream, set `tick_rate=30000/1001` since the stream is limited to a max of `15fps` -``` +```sh unifi-cam-proxy --mac '{unique MAC}' -H {NVR IP} -i {camera IP} -c /client.pem -t {Adoption token} \ reolink \ -u {username} \ diff --git a/docs/docs/configuration/reolink_nvr.md b/docs/docs/configuration/reolink_nvr.md index 72a0c91..7faa4b5 100644 --- a/docs/docs/configuration/reolink_nvr.md +++ b/docs/docs/configuration/reolink_nvr.md @@ -4,9 +4,9 @@ sidebar_position: 5 # Reolink NVR +## Options -### Options -``` +```text optional arguments: -h, --help show this help message and exit --ffmpeg-args FFMPEG_ARGS, -f FFMPEG_ARGS @@ -19,16 +19,17 @@ optional arguments: NVR password --channel CHANNEL, -c CHANNEL NVR camera channel -``` - +``` ## NVR (Reolink RLN16-410) + - [x] Supports full time recording - [x] Supports motion events - [ ] Supports smart detection - Notes: - * Camera/channel IDs are zero-based -``` + - Camera/channel IDs are zero-based + +```sh unifi-cam-proxy --mac '{unique MAC}' -H {Protect IP} -i {Reolink NVR IP} -c /client.pem -t {Adoption token} \ reolink_nvr \ -u {username} \ diff --git a/docs/docs/configuration/rtsp.md b/docs/docs/configuration/rtsp.md index 152943e..0afc7b9 100644 --- a/docs/docs/configuration/rtsp.md +++ b/docs/docs/configuration/rtsp.md @@ -4,18 +4,19 @@ sidebar_position: 1 # RTSP +Most generic cameras are supported via the RTSP integration. +Depending on your camera, you might need specific flags to make live-streaming smoother. +Check for your specific camera model in the docs before trying this. -Most generic cameras are supported via the RTSP integration. Depending on your camera, you might need specific flags to make live-streaming smoother, so check for your specific camera model in the docs before trying this. - -``` +```sh unifi-cam-proxy -H {NVR IP} -i {Camera IP} -c /client.pem -t {Adoption token} \ rtsp \ -s {rtsp stream} ``` -### Hardware Acceleration +## Hardware Acceleration -``` +```sg unifi-cam-proxy -H {NVR IP} -i {Camera IP} -c /client.pem -t {Adoption token} \ rtsp \ -s {rtsp stream} \ diff --git a/docs/docs/intro.md b/docs/docs/intro.md index aed082f..60b0af1 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -8,31 +8,40 @@ sidebar_position: 1 ## Prerequisites ### Certificate + Generate a certificate by performing one of the following: +1. If you have a UniFi camera: + + ```sh + scp ubnt@:/var/etc/persistent/server.pem client.pem + ``` -1. If you have a UniFi camera: -``` -scp ubnt@:/var/etc/persistent/server.pem client.pem -``` 2. Create your own client certificate via: -``` -openssl ecparam -out /tmp/private.key -name prime256v1 -genkey -noout -openssl req -new -sha256 -key /tmp/private.key -out /tmp/server.csr -subj "/C=TW/L=Taipei/O=Ubiquiti Networks Inc./OU=devint/CN=camera.ubnt.dev/emailAddress=support@ubnt.com" -openssl x509 -req -sha256 -days 36500 -in /tmp/server.csr -signkey /tmp/private.key -out /tmp/public.key -cat /tmp/private.key /tmp/public.key > client.pem -rm -f /tmp/private.key /tmp/public.key /tmp/server.csr -``` + + ```sh + openssl ecparam -out /tmp/private.key -name prime256v1 -genkey -noout + openssl req -new -sha256 -key /tmp/private.key -out /tmp/server.csr -subj "/C=TW/L=Taipei/O=Ubiquiti Networks Inc./OU=devint/CN=camera.ubnt.dev/emailAddress=support@ubnt.com" + openssl x509 -req -sha256 -days 36500 -in /tmp/server.csr -signkey /tmp/private.key -out /tmp/public.key + cat /tmp/private.key /tmp/public.key > client.pem + rm -f /tmp/private.key /tmp/public.key /tmp/server.csr + ``` ### Adoption Token -In order to add a camera to Protect, you must first generate an adoption token. The token is only valid for 60 minutes so you'll need to re-generate a new one if it expires during your initial setup. + +In order to add a camera to Protect, you must first generate an adoption token. +The token is only valid for 60 minutes. +You will need to re-generate a new one if it expires during your initial setup. Open https://{NVR IP}/proxy/protect/api/cameras/manage-payload and copy the token field. ## Docker -Using Docker is the recommended installation method. The sample docker-compose file below is the recommended deployment for most users. Note that the certificate generated in the previous step must be in the same directory as the docker-compose.yaml file. -``` +Using Docker is the recommended installation method. +The sample docker-compose file below is the recommended deployment for most users. +Note, the generated certificate must be in the same directory as the `docker-compose.yaml` file. + +```yaml version: "3.9" services: unifi-cam-proxy: @@ -44,11 +53,14 @@ services: ``` ### Multiple cameras -To use multiple cameras, start an instance of the proxy for each, with a unique MAC address argument. Using docker-compose, your setup might look like the following: -*** Note: This conforms to MAC randomization rules, so should not cause issues with real devices. See here for more details: https://www.mist.com/get-to-know-mac-address-randomization-in-2020/ *** +To use multiple cameras, start an instance of the proxy for each, with a unique MAC address argument. +Using docker-compose, your setup might look like the following: -``` +***Note: This conforms to MAC randomization rules, so should not cause issues with real devices.*** +***See here for more details: *** + +```yaml version: "3.5" services: proxy-1: @@ -56,22 +68,35 @@ services: image: keshavdv/unifi-cam-proxy volumes: - "./client.pem:/client.pem" - command: unifi-cam-proxy --host {NVR IP} --mac 'AA:BB:CC:00:11:22' --cert /client.pem --token {Adoption token} rtsp -s rtsp://192.168.201.15:8554/cam' + command: >- + unifi-cam-proxy + --host {NVR IP} + --mac 'AA:BB:CC:00:11:22' + --cert /client.pem + --token {Adoption token} + rtsp -s rtsp://192.168.201.15:8554/cam proxy-2: restart: unless-stopped image: keshavdv/unifi-cam-proxy volumes: - "./client.pem:/client.pem" - command: unifi-cam-proxy --host {NVR IP} --mac 'AA:BB:CC:33:44:55' --cert /client.pem --token {Adoption token} rtsp -s rtsp://192.168.201.15:8554/cam' + command: >- + unifi-cam-proxy + --host {NVR IP} + --mac 'AA:BB:CC:33:44:55' + --cert /client.pem + --token {Adoption token} + rtsp -s rtsp://192.168.201.15:8554/cam ``` - - ## Bare Metal -If you cannot use Docker, you may install the proxy on most Linux distros, but support is not guaranteed. Find instructions for your distro below: + +If you cannot use Docker, you may install the proxy on most Linux distros, but support is not guaranteed. +Find instructions for your distro below: ### Ubuntu/Debian -``` + +```sh apt install ffmpeg netcat python3 python3-pip pip3 install unifi-cam-proxy unifi-cam-proxy --host {NVR IP} --cert /client.pem --token {Adoption token} rtsp -s rtsp://192.168.201.15:8554/cam' diff --git a/docs/package.json b/docs/package.json index f03b796..c66a2ef 100644 --- a/docs/package.json +++ b/docs/package.json @@ -34,4 +34,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +} diff --git a/docs/src/pages/markdown-page.md b/docs/src/pages/markdown-page.md deleted file mode 100644 index 9756c5b..0000000 --- a/docs/src/pages/markdown-page.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Markdown page example ---- - -# Markdown page example - -You don't need React to write simple standalone pages. diff --git a/docs/static/img/logo.svg b/docs/static/img/logo.svg index 9db6d0d..ad9d11a 100644 --- a/docs/static/img/logo.svg +++ b/docs/static/img/logo.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/docs/static/img/undraw_docusaurus_tree.svg b/docs/static/img/undraw_docusaurus_tree.svg index a05cc03..4bbfbf1 100644 --- a/docs/static/img/undraw_docusaurus_tree.svg +++ b/docs/static/img/undraw_docusaurus_tree.svg @@ -1 +1 @@ -docu_tree \ No newline at end of file +docu_tree diff --git a/unifi/cams/frigate.py b/unifi/cams/frigate.py index e2fad58..35c067d 100644 --- a/unifi/cams/frigate.py +++ b/unifi/cams/frigate.py @@ -102,7 +102,7 @@ async def handle_detection_events(self, client) -> None: object_type = self.label_to_object_type(label) if not object_type: self.logger.warning( - f"Received unsupport detection label type: {label}" + f"Received unsupported detection label type: {label}" ) if not self.event_id and frigate_msg["type"] == "new": From b2ee23c63a774ef52a42749582cd96c155f40e7e Mon Sep 17 00:00:00 2001 From: Dov Benyomin Sohacheski Date: Wed, 30 Aug 2023 07:33:01 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=20Add=20CI=20step=20f?= =?UTF-8?q?or=20pre-commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 27 ++++++++++----------------- .github/workflows/image.yml | 27 ++++++++++++++------------- .markdownlint.yaml | 2 +- .pre-commit-config.yaml | 10 ++++++++++ pyproject.toml | 1 + 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7464510..63bdcfa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: paths-ignore: - docs/** - .github/workflows/docs.yml + pull_request: branches: [ main ] paths-ignore: @@ -16,31 +17,23 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: matrix: python-version: [3.9] steps: - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: pyproject.toml + - name: Install dependencies - run: | - python -m pip install --upgrade pip virtualenv - virtualenv venv - source venv/bin/activate - pip install -e .[test] - - name: Lint with flake8 - run: | - source venv/bin/activate - flake8 --show-source --statistics - - name: Check imports with isort - run: | - source venv/bin/activate - isort . --check-only --diff - - name: Run Pyre - run: | - source venv/bin/activate - pyre check + run: pip install -e .[test] + + - name: Lint with pre-commit + run: pre-commit run --all-files diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index c7d659a..d47f429 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -1,19 +1,21 @@ name: Build Docker image + on: push: branches: main tags: - v* + workflow_dispatch: + jobs: buildx: runs-on: ubuntu-latest + steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Prepare + - uses: actions/checkout@v3 + + - name: Prepare id: prep run: | DOCKER_IMAGE=keshavdv/unifi-cam-proxy @@ -33,21 +35,20 @@ jobs: echo "tags=${TAGS}" >> $GITHUB_OUTPUT echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx + + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub + + - name: Login to DockerHub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push + + - name: Build and push uses: docker/build-push-action@v4 with: context: . diff --git a/.markdownlint.yaml b/.markdownlint.yaml index e9e882d..4486d6a 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -5,4 +5,4 @@ MD013: line_length: 100 code_block_line_length: 120 -MD041: false \ No newline at end of file +MD041: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b087fb1..05461f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,3 +36,13 @@ repos: rev: 6.1.0 hooks: - id: flake8 + + - repo: local + hooks: + - id: pyre + name: pyre + entry: pyre check + pass_filenames: false + language: python + types: + - python diff --git a/pyproject.toml b/pyproject.toml index 5c87912..b1b5722 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ test = [ "isort", "flake8", "flake8-bugbear", + "pre-commit", "pyre-check", "pytest", "wheel"