Dateien nach "sip_trigger" hochladen
This commit is contained in:
parent
7827cb4c6e
commit
6c336295fd
|
|
@ -0,0 +1,3 @@
|
||||||
|
# SIP Trigger Add-on (TTS Advanced)
|
||||||
|
|
||||||
|
Dieses Add-on erlaubt es, bei einem eingehenden Anruf via SIP MQTT-Nachrichten zu senden. Zusätzlich können per TTS Textnachrichten bei PIN-Abfrage, Erfolg oder Fehler gesprochen werden.
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
sip_account sip:{{ sip_user }}@{{ sip_host }};auth_user={{ sip_user }};auth_pass={{ sip_password }};outbound=sip:{{ sip_host }}
|
||||||
|
|
||||||
|
sipnat no
|
||||||
|
sip_listen 0.0.0.0:5060
|
||||||
|
sip_trans_bsize 512
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "SIP Trigger Multi TTS Advanced",
|
||||||
|
"version": "1.3",
|
||||||
|
"slug": "sip_trigger_multi_tts_advanced",
|
||||||
|
"description": "Mehrere SIP-Accounts mit TTS bei PIN-Eingabe, Erfolg oder Fehler",
|
||||||
|
"startup": "services",
|
||||||
|
"boot": "auto",
|
||||||
|
"arch": ["amd64", "aarch64", "armv7"]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
name: SIP Trigger Add-on (TTS Advanced)
|
||||||
|
version: "1.3"
|
||||||
|
slug: sip_trigger_multi_tts_advanced
|
||||||
|
description: "Mehrere SIP-Accounts mit separaten TTS-Texten für PIN-Eingabe, Erfolg & Fehler"
|
||||||
|
startup: services
|
||||||
|
boot: auto
|
||||||
|
options:
|
||||||
|
accounts:
|
||||||
|
- sip_user: "620"
|
||||||
|
sip_password: "geheim"
|
||||||
|
sip_host: "192.168.178.1"
|
||||||
|
mqtt_host: "mqtt.local"
|
||||||
|
mqtt_topic: "sip/trigger/1"
|
||||||
|
mqtt_payload: "incoming_call"
|
||||||
|
pin_required: true
|
||||||
|
pin_code: "1234"
|
||||||
|
tts_pin_prompt_enabled: true
|
||||||
|
tts_pin_prompt_text: "Bitte geben Sie Ihre PIN ein."
|
||||||
|
tts_success_enabled: true
|
||||||
|
tts_success_text: "Willkommen. Zugriff gewährt."
|
||||||
|
tts_failure_enabled: false
|
||||||
|
tts_failure_text: "Falsche Eingabe. Verbindung wird beendet."
|
||||||
|
- sip_user: "621"
|
||||||
|
sip_password: "geheim2"
|
||||||
|
sip_host: "192.168.178.1"
|
||||||
|
mqtt_host: "mqtt.local"
|
||||||
|
mqtt_topic: "sip/trigger/2"
|
||||||
|
mqtt_payload: "call_2"
|
||||||
|
pin_required: false
|
||||||
|
tts_pin_prompt_enabled: false
|
||||||
|
tts_pin_prompt_text: ""
|
||||||
|
tts_success_enabled: false
|
||||||
|
tts_success_text: ""
|
||||||
|
tts_failure_enabled: false
|
||||||
|
tts_failure_text: ""
|
||||||
|
schema:
|
||||||
|
accounts:
|
||||||
|
- sip_user: str
|
||||||
|
sip_password: str
|
||||||
|
sip_host: str
|
||||||
|
mqtt_host: str
|
||||||
|
mqtt_topic: str
|
||||||
|
mqtt_payload: str
|
||||||
|
pin_required: bool
|
||||||
|
pin_code: str
|
||||||
|
tts_pin_prompt_enabled: bool
|
||||||
|
tts_pin_prompt_text: str
|
||||||
|
tts_success_enabled: bool
|
||||||
|
tts_success_text: str
|
||||||
|
tts_failure_enabled: bool
|
||||||
|
tts_failure_text: str
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mkdir -p /root/.baresip
|
||||||
|
|
||||||
|
echo "[*] Starte baresip für mehrere Accounts mit TTS-Unterstützung..."
|
||||||
|
|
||||||
|
i=0
|
||||||
|
for account in $(jq -c '.accounts[]' /data/options.json); do
|
||||||
|
SIP_USER=$(echo $account | jq -r '.sip_user')
|
||||||
|
SIP_PASS=$(echo $account | jq -r '.sip_password')
|
||||||
|
SIP_HOST=$(echo $account | jq -r '.sip_host')
|
||||||
|
MQTT_HOST=$(echo $account | jq -r '.mqtt_host')
|
||||||
|
MQTT_TOPIC=$(echo $account | jq -r '.mqtt_topic')
|
||||||
|
MQTT_PAYLOAD=$(echo $account | jq -r '.mqtt_payload')
|
||||||
|
PIN_REQUIRED=$(echo $account | jq -r '.pin_required')
|
||||||
|
PIN_CODE=$(echo $account | jq -r '.pin_code')
|
||||||
|
TTS_PROMPT_ENABLED=$(echo $account | jq -r '.tts_pin_prompt_enabled')
|
||||||
|
TTS_PROMPT_TEXT=$(echo $account | jq -r '.tts_pin_prompt_text')
|
||||||
|
TTS_SUCCESS_ENABLED=$(echo $account | jq -r '.tts_success_enabled')
|
||||||
|
TTS_SUCCESS_TEXT=$(echo $account | jq -r '.tts_success_text')
|
||||||
|
TTS_FAILURE_ENABLED=$(echo $account | jq -r '.tts_failure_enabled')
|
||||||
|
TTS_FAILURE_TEXT=$(echo $account | jq -r '.tts_failure_text')
|
||||||
|
|
||||||
|
mkdir -p /root/.baresip$i
|
||||||
|
cat /baresip.conf.j2 | sed "s|{{ sip_user }}|$SIP_USER|g" | sed "s|{{ sip_password }}|$SIP_PASS|g" | sed "s|{{ sip_host }}|$SIP_HOST|g" > /root/.baresip$i/config
|
||||||
|
|
||||||
|
(
|
||||||
|
HOME=/root/.baresip$i baresip | while read -r line; do
|
||||||
|
echo "[$SIP_USER] $line"
|
||||||
|
|
||||||
|
if echo "$line" | grep -q "incoming call from"; then
|
||||||
|
echo "[*][$SIP_USER] Eingehender Anruf erkannt."
|
||||||
|
|
||||||
|
if [ "$PIN_REQUIRED" = "true" ]; then
|
||||||
|
if [ "$TTS_PROMPT_ENABLED" = "true" ]; then
|
||||||
|
espeak "$TTS_PROMPT_TEXT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dtmf=""
|
||||||
|
timeout=10
|
||||||
|
end=$((SECONDS + timeout))
|
||||||
|
while [ $SECONDS -lt $end ]; do
|
||||||
|
read -t 1 -r input
|
||||||
|
dtmf="$input"
|
||||||
|
if [ "$dtmf" = "$PIN_CODE" ]; then
|
||||||
|
echo "[*][$SIP_USER] PIN korrekt!"
|
||||||
|
mosquitto_pub -h "$MQTT_HOST" -t "$MQTT_TOPIC" -m "$MQTT_PAYLOAD"
|
||||||
|
if [ "$TTS_SUCCESS_ENABLED" = "true" ]; then
|
||||||
|
espeak "$TTS_SUCCESS_TEXT"
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$dtmf" != "$PIN_CODE" ]; then
|
||||||
|
echo "[*][$SIP_USER] Falsche PIN eingegeben."
|
||||||
|
if [ "$TTS_FAILURE_ENABLED" = "true" ]; then
|
||||||
|
espeak "$TTS_FAILURE_TEXT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[*][$SIP_USER] Kein PIN nötig – sende MQTT"
|
||||||
|
mosquitto_pub -h "$MQTT_HOST" -t "$MQTT_TOPIC" -m "$MQTT_PAYLOAD"
|
||||||
|
if [ "$TTS_SUCCESS_ENABLED" = "true" ]; then
|
||||||
|
espeak "$TTS_SUCCESS_TEXT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
) &
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
Loading…
Reference in New Issue