Re: [TUTO] Notifications Domoticz par la Google Home
Publié : 15 mars 2018, 20:29
je presume que dans notification tu es ok ?

voilà mon code, remplace le tient, on sait jamais, bien sur mets ton IP
à la fin de ton message mets 0.5 0
0.5 pour volume 50% et 0 pour pas de jingle

voilà mon code, remplace le tient, on sait jamais, bien sur mets ton IP
Code : Tout sélectionner
#!/bin/bash
# notification_google_home.sh Script de notification de message vocal sur la Google Home
# by JS Martin - 11/02/2018 - version 0.1
message=$1 # text message
volume=$2 # 0=auto 0.1=10% 1=100%
jingle=$3 # jingle track number (0=no track 1=default track)
# ------ parameters ---------
# Autoset volume if volume=0
Start_day="0740"
Start_night="2100"
Night_vol="0.2"
Day_vol="0.4"
# number of arg correction
case "$#" in
"1")
volume="0"
jingle="0"
;;
"2")
jingle="0"
;;
"3")
;;
*)
echo "Usage: notification_google_home <text> [volume 0..1] [jingle_track]"
exit 1
;;
esac
# Jingle track
case "$jingle" in
"1")
jingle_name="/home/pi/domoticz/jingles/jingle1.mp3"
;;
"2")
jingle_name="/home/pi/domoticz/jingles/jingle2.mp3"
;;
*)
jingle_name="/home/pi/domoticz/jingles/jingle1.mp3"
;;
esac
# IP Google Home
IPGH="192.168.1.58"
echo "Notification : "$message
if [ $volume != "0" ]; then
echo "Volume : "$volume
else
CUR_TIME=`date +%H%M`
if [ $CUR_TIME -ge $Start_day -a $CUR_TIME -le $Start_night ]; then
echo "Day volume"
volume=$Day_vol
else
echo "Night volume"
volume=$Night_vol
fi
echo "Volume = automatique - set to "$volume
fi
#Set Google Home volume
sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename $IPGH -setvol $volume
#Text to WAV
sudo pico2wave -l fr-FR -w /tmp/message.wav "$message"
#WAV to MP3
sudo sox -v 0.99 /tmp/message.wav -r 48k /tmp/message.mp3 speed 1.06
#Add jingle if needed
if [ $jingle != "0" ]; then #add jingle
sudo sox $jingle_name /tmp/message.mp3 /tmp/message2.mp3
sudo cp /tmp/message2.mp3 /tmp/message.mp3
fi
#MP3 to Google Home
sudo python /home/pi/stream2chromecast/stream2chromecast.py -devicename $IPGH /tmp/message.mp30.5 pour volume 50% et 0 pour pas de jingle