Page 1 of 3
notifications to chromecast
Posted: Tuesday 13 March 2018 20:59
by curious
Our french speaking fellowers have a nice tutorial on how to send notifications to a chromecast device
http://easydomoticz.com/forum/viewtopic.php?f=17&t=5914
Unfortunately I don't get a message.
When I run the test,
Code: Select all
/home/pi/domoticz/scripts/notification_google_home.sh "There is someone at the door"
it works fine, but when I want Domoticz to notify me, a mail is send but there is no message on my chromecast.
Does one of you uses this notification-script and faced the same problem (and solved it

) ?
Is there a way to debug this ?
Re: notifications to chromecast
Posted: Thursday 15 March 2018 22:48
by curious
Solved...works fine
Just forgot to enable the custom/http action in notification settings
Re: notifications to chromecast
Posted: Sunday 18 March 2018 18:21
by sincze
Haha nice, I added the NS jingle as jingle1 and after that the message.

hilarious.
Re: notifications to chromecast
Posted: Sunday 18 March 2018 21:35
by glsf91
I changed the script a little bit to use google translate as TTS. Also used tasks-spooler to get multiple commands at about the same time queued, so nothing is lost. The original script is not working fine when executed when the first execution is still running.
Jingles is gone but I think you can add this by yourself again.
I use Ubuntu.
Install taskspooler: sudo apt install task-spooler
Install
https://github.com/pndurette/gTTS : pip install gTTS (not needed if you don't speak more then 150 characters)
Put the following scripts in /home/john/stream2chromecast:
(replace john with your user)
notification_chromecast_batch.sh
Code: Select all
#!/bin/bash
message=$1 # text message
volume=$2 # 0=auto 0.1=10% 1=100%
# ------ parameters ---------
# number of arg correction
case "$#" in
"1")
;;
"2")
;;
*)
echo "Usage: notification_chromecast_batch.sh <text> [volume 0..1]"
exit 1
;;
esac
# queue commands ; don't run at the same time twice
# run under user john otherwise python module cannot be found: gtts-cli
sudo -u john tsp -n bash -c "/home/john/stream2chromecast/notification_chromecast.sh \"$1\" $2 > /tmp/out 2>&1"
notification_chromecast.sh:
Code: Select all
#!/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
# changed by glsf91
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="0700"
Start_night="2200"
Night_vol="0.2"
Day_vol="0.7"
# number of arg correction
case "$#" in
"1")
volume="0"
jingle="1"
;;
"2")
jingle="1"
;;
*)
echo "Usage: notification_google_home <text> [volume 0..1]"
exit 1
;;
esac
# IP Google Home
IPGH="192.168.1.173"
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
# Exit if chromecast not online
ping -c1 -W 2 $IPGH >/dev/null
if [ $? -eq 0 ]
then echo "Chromecast online"
else echo "Chromecast offline"
exit 0
fi
if [ -f /tmp/message.mp3 ]
then
rm /tmp/message.mp3
fi
#Text to MP3; naturalreaders
#curl -s -G "http://api.naturalreaders.com/v4/tts/macspeak" --data "apikey=<apikey>&src=pw&r=22&s=1" --data-urlencode "t=$message" -o /tmp/message.mp3
# use google translate
if [ ${#message} -lt 150 ]
then
curl -s -G "http://translate.google.com/translate_tts" --data "ie=UTF-8&total=1&idx=0&client=tw-ob&&tl=nl-NL" --data-urlencode "q=$message" -A "Mozilla" --compressed -o /tmp/message.mp3
else
/home/john/.local/bin/gtts-cli "$message" -l 'nl' -o /tmp/message.mp3
fi
if [ -f /tmp/message.mp3 ]
then
#Set Google Home volume
sudo python /home/john/stream2chromecast/stream2chromecast/stream2chromecast.py -devicename $IPGH -setvol $volume
#MP3 to Google Home
sudo python /home/john/stream2chromecast/stream2chromecast/stream2chromecast.py -devicename $IPGH /tmp/message.mp3
fi
if [ -f /tmp/message.mp3 ]
then
rm /tmp/message.mp3
fi
I have installed stream2chromecast in /home/john/stream2chromecast/stream2chromecast. Adjust the path if necessary.
Also change the ip address of your chromecast device.
Use in Domotizc:
Code: Select all
os.execute('/home/john/stream2chromecast/notification_chromecast_batch.sh "'..sentence..'" &')
sentence is the variable with text.
You can also use naturalreaders.com instead of google. Language is dutch now (change the r=22). There is a limit of 20 minutes per day if using dutch. Only 1 english language is free above 20 minutes.
Re: notifications to chromecast
Posted: Sunday 18 March 2018 21:38
by sincze
Pretty nice. Let me try that as well. Tnx for sharing.
Re: notifications to chromecast
Posted: Sunday 18 March 2018 21:57
by sincze
haha great stuff. The modified script works like a charm.
Re: notifications to chromecast
Posted: Monday 19 March 2018 16:01
by glsf91
With the command tsp you can see the queue with the commands. Also the commands which are ready.
With tsp -C you can clear the queue.
Re: notifications to chromecast
Posted: Tuesday 20 March 2018 21:19
by freakshock
Can someone tell me if this is possible to achieve on Synology? If so, how?

Re: notifications to chromecast
Posted: Tuesday 20 March 2018 21:36
by sincze
Mmm clone stream2cast and use Google with modified script by glsf91. I think it should be possible in that way. Don't try the queue mechanism yet.
Re: notifications to chromecast
Posted: Tuesday 20 March 2018 21:56
by ropske
to what device are you sending this?

Re: notifications to chromecast
Posted: Wednesday 21 March 2018 10:06
by sincze
ropske wrote: ↑Tuesday 20 March 2018 21:56
to what device are you sending this?
At this moment to my Google Home
Re: notifications to chromecast
Posted: Wednesday 21 March 2018 18:19
by glsf91
ropske wrote: ↑Tuesday 20 March 2018 21:56
to what device are you sending this?
I use Chromecast audio.
Re: notifications to chromecast
Posted: Wednesday 21 March 2018 19:51
by sincze
Ha just curious what would happen it I would send it to my chromecast enabled tv's

probably I would lose focus on the kodi input

Re: notifications to chromecast
Posted: Wednesday 21 March 2018 20:12
by gijsje
freakshock wrote: ↑Tuesday 20 March 2018 21:19
Can someone tell me if this is possible to achieve on Synology? If so, how?
Would like to know as well
Re: notifications to chromecast
Posted: Thursday 22 March 2018 20:03
by glsf91
gijsje wrote: ↑Wednesday 21 March 2018 20:12
freakshock wrote: ↑Tuesday 20 March 2018 21:19
Can someone tell me if this is possible to achieve on Synology? If so, how?
Would like to know as well
If you can run python, give it a try. Start with trying stream2chromecast.
Re: notifications to chromecast
Posted: Thursday 22 March 2018 21:12
by curious
In my jingle I have the "NS-ding-dong" and the spoken notification. However, just a small part of the jingle is being played.
Anyone knows how to solve that ?
Solved : The mp3 had the wrong format : It has to be mono and 48Khz
Re: notifications to chromecast
Posted: Friday 23 March 2018 7:01
by DewGew
sincze wrote: ↑Wednesday 21 March 2018 19:51
Ha just curious what would happen it I would send it to my chromecast enabled tv's

probably I would lose focus on the kodi input
Has anyone tried that yet?
Re: notifications to chromecast
Posted: Monday 26 March 2018 20:00
by freakshock
glsf91 wrote: ↑Thursday 22 March 2018 20:03
gijsje wrote: ↑Wednesday 21 March 2018 20:12
freakshock wrote: ↑Tuesday 20 March 2018 21:19
Can someone tell me if this is possible to achieve on Synology? If so, how?
Would like to know as well
If you can run python, give it a try. Start with trying stream2chromecast.
I tried stream2chromecast and was able to stream an mp3 file to my chromecast audio through a Putty command.
Can't get any commands working in domoticz though, either through a script action on a dummy switch, or through lua (dzVents) but maybe I need different instructions.. any tips?
Re: notifications to chromecast
Posted: Saturday 28 April 2018 16:54
by sincze
DewGew wrote: ↑Friday 23 March 2018 7:01
sincze wrote: ↑Wednesday 21 March 2018 19:51
Ha just curious what would happen it I would send it to my chromecast enabled tv's

probably I would lose focus on the kodi input
Has anyone tried that yet?
Pieuw, totally forgot the answer you. Sorry.
I just tested to a chromecast attached to my tv.
It plays just fine.
Re: notifications to chromecast
Posted: Saturday 28 April 2018 19:53
by freijn
curious wrote: ↑Thursday 22 March 2018 21:12
In my jingle I have the "NS-ding-dong" and the spoken notification. However, just a small part of the jingle is being played.
Anyone knows how to solve that ?
Solved : The mp3 had the wrong format : It has to be mono and 48Khz
Nice Idea !! THanks
Found it as well
http://www.woubar.nl/goodies/ns.mp3