From 16b4bfdda0b43877c414d5eeac9e3420aaac100d Mon Sep 17 00:00:00 2001 From: kvanzuijlen <8818390+kvanzuijlen@users.noreply.github.com> Date: Sun, 29 Jun 2025 23:13:20 +0200 Subject: [PATCH] initial commit --- .gitignore | 3 ++ Dockerfile | 27 ++++++++++ LICENSE | 21 ++++++++ README.md | 125 +++++++++++++++++++++++++++++++++++++++++++++++ build.yaml | 11 +++++ config.yaml | 27 ++++++++++ icon.png | Bin 0 -> 1276 bytes logo.png | Bin 0 -> 1276 bytes run.sh | 29 +++++++++++ tuya_auth_qr.exp | 40 +++++++++++++++ 10 files changed, 283 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 build.yaml create mode 100644 config.yaml create mode 100644 icon.png create mode 100644 logo.png create mode 100644 run.sh create mode 100644 tuya_auth_qr.exp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eeaa70 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.idea/ +/*.iml + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aaae43f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Dockerfile for Tuya IPC Terminal Add-on +ARG BUILD_FROM +FROM golang:1.24-bookworm AS builder + +# Set up environment +ENV LANG=C.UTF-8 + +# Clone the tuya-ipc-terminal repository and install dependencies +RUN git clone https://github.com/seydx/tuya-ipc-terminal.git /usr/src/app +WORKDIR /usr/src/app +RUN chmod +x build.sh && ./build.sh + +FROM ${BUILD_FROM} + +COPY --from=builder /usr/src/app/tuya-ipc-terminal /usr/bin/ + +# Copy run script +COPY run.sh / +COPY tuya_auth_qr.exp / +RUN chmod a+x /run.sh && chmod +x /tuya_auth_qr.exp && chmod a+x /usr/bin/tuya-ipc-terminal + +RUN apt-get update && apt-get install -y expect && apt-get clean +RUN mkdir -p /config +WORKDIR /config + +# Start the application +CMD [ "/run.sh" ] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..978d2ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 kvanzuijlen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e41a017 --- /dev/null +++ b/README.md @@ -0,0 +1,125 @@ +# Home Assistant Add-on: Tuya IPC Terminal + +!license: MIT + +Expose your Tuya-based security cameras as standard RTSP streams within your local network. +This addon builds on the awesome work of @seydx on [Tuya IPC Terminal](https://github.com/seydx/tuya-ipc-terminal) +and makes integration with Home Assistant a little bit easier. + +## About + +This addon integrates the tuya-ipc-terminal application into Home Assistant. It authenticates with your Tuya account, +discovers your compatible IP cameras, and creates a local RTSP stream for each one. + +This allows you to use your Tuya cameras with any RTSP-compatible software, including Home Assistant's camera +integrations, VLC, Frigate, or other NVR systems, without relying on cloud-based P2P connections for viewing. + +## Features +- **Local RTSP Streams**: Keeps video traffic on your local network for lower latency and improved privacy. +- **Simple Authentication**: Uses a one-time QR code login process with your Tuya/Smart Life mobile app. +- **Auto-Discovery**: Automatically discovers and refreshes your camera list on startup. +- **Wide Compatibility**: Works with any RTSP-compatible client or NVR software. + +## Installation + +### Automatic + +[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL +pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg) +](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fkvanzuijlen%2Fhomeassistant-tuya-ipc-terminal-addon) + +1. Click on the button above (see the official [docs](https://my.home-assistant.io/) for more information) +2. Click Add +3. Close the dialog and refresh the page. The "Tuya IPC Terminal" addon will now appear in the store. +4. Click on the "Tuya IPC Terminal" addon and then click Install. + +### Manual + +1. Navigate to your Home Assistant instance. +2. Go to Settings > Add-ons > Add-on Store. +3. Click the 3-dots menu in the top-right corner and select Repositories. +4. Add the URL of this repository and click Add. +5. Close the dialog and refresh the page. The "Tuya IPC Terminal" addon will now appear in the store. +6. Click on the "Tuya IPC Terminal" addon and then click Install. + +## Configuration + +### Step 1: Add-on Options + +Before starting the addon, you must configure it with your Tuya account details. +1. On the addon page, go to the Configuration tab. +2. Set the following options: + - **TUYA_EMAIL**: The email address associated with your Tuya Smart or Smart Life account. + - **TUYA_REGION**: The cloud region your account is registered in. Common values are: + - eu-central + - eu-east + - us-west + - us-east + - china + - india + - See [this list](https://github.com/seydx/tuya-ipc-terminal#-authentication-management) +3. Click Save. + +### Step 2: First-Time Authentication (QR Code) + +The addon uses a one-time QR code process to securely log into your account. This QR will be valid for 20 seconds, +after which the addon will need to be restarted. + +1. Open the Tuya or Smart Life app on your smartphone. +2. Click Start to run the addon for the first time. +3. Go to the addon's Log tab on your desktop/laptop or another separate device. +4. The logs will refresh, and you will see a large QR code appear. +5. In the app, go to your profile tab and then find the Scan button (usually in the top-right corner). +6. Scan the QR code displayed in the addon logs. +7. Confirm the login on your phone. +8. The addon will automatically detect the successful login and proceed. On success, it creates a `.tuya-data` folder in +9. the `/addon_configs/966623c8_tuya_ipc_terminal` directory to store authentication tokens, so you only need to do this once. + +### Step 3: Finding Your Camera Streams + +Once authentication is complete, the addon will start the RTSP server and list the URLs for your cameras. + +1. Look at the logs again. After the authentication messages, you will see entries for each camera, like this: + ```log + 22:53:35.138 INF Available endpoints: + 22:53:35.139 INF rtsp://localhost:8554/Front_Door_Cam (Front Door Cam) + 22:53:35.139 INF rtsp://localhost:8554/Backyard_Cam (Backyard Cam) + 22:53:35.139 INF RTSP server is running. Press Ctrl+C to stop. + ``` +2. Copy the RTSP URL for the camera you wish to add to Home Assistant or another client. + +## Usage in Home Assistant + +The easiest way to add your camera to the Home Assistant dashboard is by using the Generic Camera integration. + +1. Go to Settings > Devices & Services. +2. Click Add Integration and search for Generic Camera. +3. Fill out the configuration: + - Stream Source URL: Paste the RTSP URL you copied from the addon logs. + - Authentication: Select None, as authentication is not required for the local stream. +4. Click Submit, and your camera feed should now be available as an entity in Home Assistant. + +Other ways to add your camera to Home Assistant are via integrations like Frigate or MotionEye. + +## Re-authenticating + +If your authentication token expires or you change your password, you may need to re-authenticate. + +1. Stop the Tuya IPC Terminal addon. +2. Use the File editor, Samba, or Terminal addon to access your Home Assistant configuration files. +3. Navigate to the `/addon_configs/966623c8_tuya_ipc_terminal` directory. +4. Delete the entire `.tuya-data` folder. +5. Start the Tuya IPC Terminal addon again and follow the QR code authentication steps from above. + +## Troubleshooting + +- QR Code Expired: The authentication process has a 20 second timeout. Be ready to scan the QR code as soon as it + appears in the logs. If you miss it, simply restart the addon to generate a new one. +- No Cameras Found: + - Verify that your cameras are online and visible in your Tuya Smart/Smart Life app. + - Double-check that the `TUYA_EMAIL` and `TUYA_REGION` in the addon configuration are correct. +- RTSP Stream Not Working: + - Ensure the RTSP URL is correct. + - Verify that port `8554` is correctly mapped in the addon's Network configuration section. + - Check the addon logs for any error messages related to the RTSP server. +- See the [Tuya IPC Terminal docs](https://github.com/seydx/tuya-ipc-terminal#-complete-documentation) diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..5ce7525 --- /dev/null +++ b/build.yaml @@ -0,0 +1,11 @@ +build_from: + aarch64: "homeassistant/aarch64-base-debian:bookworm" + amd64: "homeassistant/amd64-base-debian:bookworm" + armhf: "homeassistant/armhf-base-debian:bookworm" + armv7: "homeassistant/armv7-base-debian:bookworm" + i386: "homeassistant/i386-base-debian:bookworm" +labels: + org.opencontainers.image.title: "Home Assistant Add-on: Tuya IPC Terminal" + org.opencontainers.image.description: "Tuya IPC Terminal" + org.opencontainers.image.source: "https://github.com/seydx/tuya-ipc-terminal" + org.opencontainers.image.licenses: "MIT" diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..f2805ab --- /dev/null +++ b/config.yaml @@ -0,0 +1,27 @@ +# Home Assistant add-on configuration for Tuya IPC Terminal +name: Tuya IPC Terminal +version: "1.0.0" +slug: tuya_ipc_terminal +description: "Exposes Tuya camera streams as RTSP feeds" +arch: + - aarch64 + - amd64 + - armhf + - armv7 + - i386 +init: false +startup: "application" +boot: "auto" +options: + TUYA_EMAIL: "" + TUYA_REGION: "eu-central" +schema: + TUYA_EMAIL: "email" + TUYA_REGION: "str" +ports: + 8554/tcp: 8554 +ports_description: + 8554/tcp: "RTSP stream" +map: + - type: addon_config + read_only: False diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ef8fbcdcc16cef5dfd034a69f6a4bdbc27dcc881 GIT binary patch literal 1276 zcmVuB-ZlB5XK0ogJ zeSO~NeV_N0BvI3=bM>Xx(j{%sPXTn&xMSNGb?5Xe`u%FPI+8c*rIh5jsJms_%lrVL zg3Ua)XS*p)%ljTw+`Px5x;M1Bh?WsW3X22Z9%6uE1 zG-B3z4_@lH3cRlIum2E|GhJS4fwi-M3tziUIPAcoEu)*D^~DLmJ4WEsoxra@vi?pd zaIAdv{zFLo0olC&n%lff{k=d&xY(A5np{2fFJ+GjxcfI7qo&NS5XuA8ANDryk|kDb z>j}LEem)O$wgPqJS};Yh;)urs%i3+hF$M^-H7^VSvF=Q30By)cN_@jkf+%w2=!tI+Zl=cC!p9g^lp!4$u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