tuya-ipc-terminal/run.sh aktualisiert
This commit is contained in:
parent
dfcf2f9eee
commit
3b91eae065
@ -1,25 +1,49 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
# 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."
|
||||
# Prüfen, ob Konfiguration vorhanden ist
|
||||
if [[ -z "${TUYA_EMAIL}" || -z "${TUYA_PASSWORD}" ]]; then
|
||||
bashio::log.fatal "Tuya-E-Mail und Passwort müssen konfiguriert sein."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "${TUYA_PASSWORD}" ]]; then
|
||||
bashio::log.fatal "Please configure your Tuya password in the addon options."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Authenticate with Tuya
|
||||
bashio::log.info "Authenticating with Tuya using email/password..."
|
||||
# --- Start: Authentifizierung beim Start ---
|
||||
bashio::log.info "Authentifizierung bei Tuya..."
|
||||
printf "%s\n%s\n%s\n" "${TUYA_REGION}" "${TUYA_EMAIL}" "${TUYA_PASSWORD}" | /tuya_auth_login.exp
|
||||
# --- Ende: Authentifizierung beim Start ---
|
||||
|
||||
# Rest bleibt gleich...
|
||||
tuya-ipc-terminal cameras refresh
|
||||
tuya-ipc-terminal rtsp start --port 8554
|
||||
|
||||
# Starte den RTSP-Server im Hintergrund
|
||||
bashio::log.info "Starte den Tuya RTSP-Server im Hintergrund..."
|
||||
tuya-ipc-terminal rtsp start --port 8554 &
|
||||
# Speichere die Prozess-ID (PID) des RTSP-Servers
|
||||
RTSP_PID=$!
|
||||
bashio::log.info "RTSP-Server gestartet mit PID ${RTSP_PID}."
|
||||
|
||||
|
||||
# --- Start: Watchdog-Schleife ---
|
||||
bashio::log.info "Starte den Watchdog zur Überwachung der Sitzung."
|
||||
while true; do
|
||||
# Warte für 15 Minuten bevor der nächste Check durchgeführt wird
|
||||
sleep 900
|
||||
|
||||
bashio::log.info "Watchdog: Überprüfe den Status der Tuya-Sitzung..."
|
||||
RESPONSE=$(tuya-ipc-terminal cameras refresh 2>&1)
|
||||
|
||||
# Prüfe auf Sitzungsfehler
|
||||
if echo "${RESPONSE}" | grep -q -E "401|USER_SESSION_LOSS|Not login"; then
|
||||
bashio::log.error "Watchdog: Abgelaufene Sitzung erkannt! Starte das Addon neu."
|
||||
|
||||
# Beende den RTSP-Server-Prozess, damit das Addon sauber neu gestartet werden kann
|
||||
kill "${RTSP_PID}"
|
||||
|
||||
# Das Beenden des Skripts (exit 1) veranlasst den Supervisor zum Neustart
|
||||
exit 1
|
||||
else
|
||||
bashio::log.info "Watchdog: Sitzung ist weiterhin gültig."
|
||||
fi
|
||||
done
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user