Compare commits
45 Commits
renovate/g
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 690800ec14 | |||
| 41f93a9dd9 | |||
| 603544b57c | |||
| e2ba56031c | |||
| 2442d8f4e5 | |||
| 06b14e7dd9 | |||
| 1c69804531 | |||
| 3cfdcbf0ce | |||
| fea79252f1 | |||
| 3673d88c89 | |||
| 7c33197953 | |||
| e36af376b5 | |||
| 45ae593fe9 | |||
| 4e40910753 | |||
| 6140e7fcef | |||
| 3f0241affd | |||
| 5be3783208 | |||
| aaff7b1217 | |||
| 745371759d | |||
| 8ecc245aab | |||
| 3b91eae065 | |||
| dfcf2f9eee | |||
| e7e9673b4a | |||
| 9885cd63a5 | |||
| 715d82c3a9 | |||
| 557f5cc32a | |||
| f3402cfd9b | |||
| 09da1bded4 | |||
| 7f9e25bf92 | |||
| 392d40dff9 | |||
| 0d0e466ff3 | |||
| 47a46209ae | |||
| 8324f4a2b7 | |||
| f202354c42 | |||
| 278f9040f6 | |||
| 31cd6544f7 | |||
| 383b25c138 | |||
| 78624d7935 | |||
| f9e35a7f32 | |||
| d7494f8250 | |||
| 1b62319289 | |||
| 4d28149375 | |||
| 18c1621556 | |||
| b68d88bba0 | |||
| aa2ed32047 |
@ -1,3 +1,3 @@
|
||||
name: "HA Add-ons by kvanzuijlen"
|
||||
url: "https://github.com/kvanzuijlen/homeassistant-tuya-ipc-terminal-addon"
|
||||
maintainer: "kvanzuijlen"
|
||||
name: "HA Add-ons by kvanzuijlen & Julian"
|
||||
url: "https://git.xn--julianbrger-zhb.de/admin/homeassistant-tuya-ipc-terminal-addon"
|
||||
maintainer: "Julian"
|
||||
|
||||
@ -16,8 +16,8 @@ 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
|
||||
COPY tuya_auth_login.exp /
|
||||
RUN chmod a+x /run.sh && chmod +x /tuya_auth_login.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
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Home Assistant add-on configuration for Tuya IPC Terminal
|
||||
name: Tuya IPC Terminal
|
||||
version: "1.0.0"
|
||||
version: "1.0.19"
|
||||
slug: tuya_ipc_terminal
|
||||
description: "Exposes Tuya camera streams as RTSP feeds"
|
||||
arch:
|
||||
@ -14,10 +14,12 @@ startup: "application"
|
||||
boot: "auto"
|
||||
options:
|
||||
TUYA_EMAIL: ""
|
||||
TUYA_PASSWORD: ""
|
||||
TUYA_REGION: "eu-central"
|
||||
schema:
|
||||
TUYA_EMAIL: "email"
|
||||
TUYA_REGION: "str"
|
||||
TUYA_EMAIL: str
|
||||
TUYA_PASSWORD: password
|
||||
TUYA_REGION: list(eu-central|eu-east|us-west|us-east|china|india)
|
||||
ports:
|
||||
8554/tcp: 8554
|
||||
ports_description:
|
||||
|
||||
@ -1,29 +1,69 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Home Assistant Add-on: Tuya IPC Terminal
|
||||
#
|
||||
# This script starts the Tuya IPC Terminal application with the configured
|
||||
# options.
|
||||
# ==============================================================================
|
||||
|
||||
# Read configuration options
|
||||
# Konfiguration lesen
|
||||
readonly TUYA_EMAIL=$(bashio::config 'TUYA_EMAIL')
|
||||
readonly TUYA_PASSWORD=$(bashio::config 'TUYA_PASSWORD')
|
||||
readonly TUYA_REGION=$(bashio::config 'TUYA_REGION')
|
||||
|
||||
# Check if required options are set
|
||||
if [[ -z "${TUYA_EMAIL}" ]]; then
|
||||
bashio::log.fatal "Please configure your Tuya email in the addon options."
|
||||
if [[ -z "${TUYA_EMAIL}" || -z "${TUYA_PASSWORD}" ]]; then
|
||||
bashio::log.fatal "Tuya-E-Mail und Passwort müssen konfiguriert sein."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Authenticate with Tuya
|
||||
bashio::log.info "Authenticating with Tuya..."
|
||||
printf "%s\n%s\n" "${TUYA_REGION}" "${TUYA_EMAIL}" | /tuya_auth_qr.exp
|
||||
# --- START: Authentifizierung und Kamera-Sync ---
|
||||
bashio::log.info "Authentifizierung bei Tuya..."
|
||||
printf "%s\n%s\n%s\n" "${TUYA_REGION}" "${TUYA_EMAIL}" "${TUYA_PASSWORD}" | /tuya_auth_login.exp
|
||||
|
||||
# Refresh camera list
|
||||
bashio::log.info "Refreshing camera list..."
|
||||
tuya-ipc-terminal cameras refresh
|
||||
bashio::log.info "Synchronisiere Kameraliste mit Tuya-Cloud..."
|
||||
RETRIES=5
|
||||
SUCCESS=false
|
||||
for i in $(seq 1 $RETRIES); do
|
||||
bashio::log.info "Versuch ${i}/${RETRIES}, die Kameraliste abzurufen..."
|
||||
if tuya-ipc-terminal cameras refresh; then
|
||||
bashio::log.info "Kameraliste erfolgreich synchronisiert."
|
||||
SUCCESS=true
|
||||
break
|
||||
fi
|
||||
bashio::log.warning "Fehler bei der Synchronisierung der Kameras. Warte 10 Sekunden."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
# Start the RTSP server
|
||||
bashio::log.info "Starting RTSP server on port 8554..."
|
||||
tuya-ipc-terminal rtsp start --port 8554
|
||||
if [ "$SUCCESS" = false ]; then
|
||||
bashio::log.fatal "Konnte Kameraliste nach ${RETRIES} Versuchen nicht abrufen. Addon wird beendet."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Starte den RTSP-Server und den Watchdog ---
|
||||
bashio::log.info "Starte den Tuya RTSP-Server im Hintergrund..."
|
||||
tuya-ipc-terminal rtsp start --port 8554 &
|
||||
RTSP_PID=$!
|
||||
sleep 2
|
||||
bashio::log.info "RTSP-Server gestartet mit PID ${RTSP_PID}."
|
||||
|
||||
# --- KORRIGIERTE PRÜFUNG (OHNE 'ps') ---
|
||||
if [ ! -d "/proc/${RTSP_PID}" ]; then
|
||||
bashio::log.fatal "RTSP-Server konnte nicht gestartet werden oder ist sofort abgestürzt."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bashio::log.info "Starte den Watchdog zur Überwachung der Sitzung."
|
||||
while true; do
|
||||
sleep 900
|
||||
|
||||
# --- KORRIGIERTE PRÜFUNG (OHNE 'ps') ---
|
||||
if [ ! -d "/proc/${RTSP_PID}" ]; then
|
||||
bashio::log.error "Watchdog: RTSP-Server-Prozess nicht gefunden! Starte das Addon neu."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bashio::log.info "Watchdog: Überprüfe den Status der Tuya-Sitzung..."
|
||||
RESPONSE=$(tuya-ipc-terminal cameras refresh 2>&1)
|
||||
|
||||
if echo "${RESPONSE}" | grep -q -E "401|USER_SESSION_LOSS|Not login"; then
|
||||
bashio::log.error "Watchdog: Abgelaufene Sitzung erkannt! Starte das Addon neu."
|
||||
kill "${RTSP_PID}"
|
||||
exit 1
|
||||
else
|
||||
bashio::log.info "Watchdog: Sitzung ist gültig und RTSP-Server läuft."
|
||||
fi
|
||||
done
|
||||
|
||||
63
tuya-ipc-terminal/tuya_auth_login.exp
Normal file
63
tuya-ipc-terminal/tuya_auth_login.exp
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
# Aktiviere internes Debugging, um den Ablauf zu verfolgen
|
||||
exp_internal 1
|
||||
puts "DEBUG: Expect-Skript gestartet."
|
||||
|
||||
# Entferne alte Konfiguration, um eine neue Sitzung zu erzwingen
|
||||
set config_dir "/config/.tuya-data"
|
||||
if { [file isdirectory $config_dir] } {
|
||||
puts "DEBUG: Altes Konfigurationsverzeichnis gefunden, wird entfernt."
|
||||
if {[catch {file delete -force -- $config_dir} err]} {
|
||||
puts stderr "FATAL: Konnte Verzeichnis '$config_dir' nicht löschen: $err"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
puts "DEBUG: Starte Authentifizierungsprozess."
|
||||
set timeout 60
|
||||
|
||||
# Lese Eingaben
|
||||
gets stdin region
|
||||
gets stdin email
|
||||
gets stdin password
|
||||
|
||||
if { $region eq "" || $email eq "" || $password eq "" } {
|
||||
puts stderr "FATAL: Eine der Eingaben ist leer."
|
||||
exit 1
|
||||
}
|
||||
|
||||
spawn tuya-ipc-terminal auth add $region $email --password
|
||||
|
||||
# --- START DER ENTSCHEIDENDEN KORREKTUR ---
|
||||
# Verwende einen regulären Ausdruck (-re), der auf verschiedene Passwortabfragen reagiert.
|
||||
# "Enter ?[Pp]assword:" fängt "Enter password:" und "Enter Password:" ab.
|
||||
expect {
|
||||
-re {Password:|Enter ?[Pp]assword:?|Please enter your password:} {
|
||||
puts "DEBUG: Passwortabfrage erkannt. Sende Passwort..."
|
||||
send "$password\r"
|
||||
puts "DEBUG: Passwort gesendet."
|
||||
# exp_continue sorgt dafür, dass das Skript auf weitere Ausgaben wartet
|
||||
exp_continue
|
||||
}
|
||||
# --- ENDE DER KORREKTUR ---
|
||||
|
||||
"Authentication successful" {
|
||||
puts "DEBUG: Erfolgsmeldung 'Authentication successful' erkannt."
|
||||
# Warte, bis der Prozess sich beendet hat
|
||||
catch {expect eof}
|
||||
catch {wait}
|
||||
exit 0
|
||||
}
|
||||
eof {
|
||||
puts "DEBUG: Prozess hat sich beendet (EOF)."
|
||||
# Prüfe den Exit-Code des beendeten Prozesses
|
||||
set exit_code [lindex [wait] 2]
|
||||
puts "DEBUG: Prozess beendet mit Exit-Code $exit_code."
|
||||
exit $exit_code
|
||||
}
|
||||
timeout {
|
||||
puts stderr "FATAL: Timeout nach 60 Sekunden."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
# Check if the config directory already exists.
|
||||
set config_dir "/config/.tuya-data"
|
||||
if { [file isdirectory $config_dir] } {
|
||||
# If it exists, print a message and exit successfully.
|
||||
puts "Skipping authentication: Configuration directory '$config_dir' already exists. To re-authenticate, delete the folder from the addon config folder."
|
||||
exit 0
|
||||
}
|
||||
|
||||
# If the directory does not exist, proceed with authentication.
|
||||
puts "Configuration directory not found. Proceeding with authentication..."
|
||||
|
||||
# Set a timeout for the expect command to wait for a response.
|
||||
set timeout 20
|
||||
|
||||
# Read the region from the first line of standard input.
|
||||
gets stdin region
|
||||
if { [eof stdin] || $region eq "" } {
|
||||
puts stderr "Error: Could not read region from stdin or region is empty."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Read the email from the second line of standard input.
|
||||
gets stdin email
|
||||
if { [eof stdin] || $email eq "" } {
|
||||
puts stderr "Error: Could not read email from stdin or email is empty."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Spawn the tuya-ipc-terminal command, using the email variable.
|
||||
spawn tuya-ipc-terminal auth add $region $email --qr
|
||||
|
||||
expect "Press Enter after scanning to continue"
|
||||
|
||||
# Send the Enter key
|
||||
send "\r"
|
||||
|
||||
expect eof
|
||||
wait
|
||||
Loading…
x
Reference in New Issue
Block a user