Here my API call script. I cleaned it up a little bit.
#!/bin/bash
#
# ------------------------------------------------------------------------------
# Aufruf: sh /home/ortin/Homation/tts.sh text01
# ------------------------------------------------------------------------------
# Variablendeklaration
# ------------------------------------------------------------------------------
user=nobody
pwd=0815
addr=localhost
textNr=$1
case $hausCheck in
OK) text="Alles tutti""
;;
NOK) flur=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-fenster-flur | jq -r .variable.value`
hwr=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-tuer-hwr-garage | jq -r .variable.value`
terrasse=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-tuer-terrasse | jq -r .variable.value`
wc=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-fenster-wc | jq -r .variable.value`
schlafzimmer=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-fenster-schlafzimmer | jq -r .variable.value`
bad=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-fenster-bad | jq -r .variable.value`
garagentorLi=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-tor-garage-links | jq -r .variable.value`
garagentorRe=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-tor-garage-rechts | jq -r .variable.value`
garagentuer=` curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-tuer-garagenaussentuer | jq -r .variable.value`
gartenhaustuer=`curl -s -u $user:$pwd $addr:1234/api/variables/kontakt-tuer-gartenhaus | jq -r .variable.value`
nukiHWR=` curl -s -u $user:$pwd $addr:1234/api/variables/nuki-status-schloss | jq -r .variable.value`
if [ $flur = offen ]
then sag1="das Fenster im Flur,"
fi
if [ $hwr = offen ]
then sag2="die Tür im HWR,"
fi
if [ $terrasse = offen ]
then sag3="die Tür zur Terrasse,"
fi
if [ $wc = offen ]
then sag4="das Fenster im WC,"
fi
if [ $schlafzimmer = offen ]
then sag5="das Fenster im Schlafzimmer,"
fi
if [ $bad = offen ]
then sag6="das Fenster im Bad,"
fi
if [ $garagentorLi = offen ]
then sag7="das Garagentor links,"
fi
if [ $garagentorRe = offen ]
then sag8="das Garagentor rechts,"
fi
if [ $garagentuer = offen ]
then sag9="die Garagenaußentür,"
fi
if [ $gartenhaustuer = offen ]
then sag10="die Gartenhaustür,"
fi
if [ $nukiHWR = offen ]
then sag11="den HWR Nucki,"
fi
then text="Check bitte $sag1 $sag2 $sag3 $sag4 $sag5 $sag6 $sag7 $sag8 $sag9 $sag10 $sag11"
esac
# ------------------------------------------------------------------------------
# Übergabe an GoogleHome
# ------------------------------------------------------------------------------
# Google Home
curl -s -X PATCH -H "Content-Type:application/json" -u "$user:$pwd" -d '{"type": "value", "valueOrExpression": "'"$text"'"}' $addr:1234/api/variables/tts-text-input
# ------------------------------------------------------------------------------
exit 0
To announce the $text I am using a variableInputDevice
and a rule which reacts on the change of it (I am using this for many different announcements, therefore I am going this way.
The rule looks like this:
When $tts-text-input gets updated then play text "$tts-text-input" vol $tts-lautstaerke on google-nest-hub-wohnzimmer
Hope it helps.