notifications to chromecast

Alexa, Google Home and Siri

Moderator: leecollings

curious
Posts: 132
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

notifications to chromecast

Post 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 ?
curious
Posts: 132
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

Re: notifications to chromecast

Post by curious »

Solved...works fine :)

Just forgot to enable the custom/http action in notification settings
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: notifications to chromecast

Post by sincze »

Haha nice, I added the NS jingle as jingle1 and after that the message. :lol: hilarious.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post 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.
Last edited by glsf91 on Tuesday 08 January 2019 19:03, edited 1 time in total.
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: notifications to chromecast

Post by sincze »

Pretty nice. Let me try that as well. Tnx for sharing.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: notifications to chromecast

Post by sincze »

haha great stuff. The modified script works like a charm.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post 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.
freakshock
Posts: 64
Joined: Friday 14 April 2017 13:39
Target OS: NAS (Synology & others)
Domoticz version:
Location: The Netherlands
Contact:

Re: notifications to chromecast

Post by freakshock »

Can someone tell me if this is possible to achieve on Synology? If so, how? :?:
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: notifications to chromecast

Post 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.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
ropske
Posts: 483
Joined: Tuesday 12 August 2014 5:37
Target OS: Raspberry Pi / ODroid
Domoticz version: V3_8394
Location: Rumbeke,Belgium
Contact:

Re: notifications to chromecast

Post by ropske »

to what device are you sending this? :oops:
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: notifications to chromecast

Post by sincze »

ropske wrote: Tuesday 20 March 2018 21:56 to what device are you sending this? :oops:
At this moment to my Google Home
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post by glsf91 »

ropske wrote: Tuesday 20 March 2018 21:56 to what device are you sending this? :oops:
I use Chromecast audio.
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: notifications to chromecast

Post 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 :)
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
gijsje
Posts: 132
Joined: Saturday 19 August 2017 14:28
Target OS: NAS (Synology & others)
Domoticz version: Stable
Location: Berkel Enschot, NL
Contact:

Re: notifications to chromecast

Post 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
Synology DS218+ - RFXtrx433 - Aeotec Z-Stick Gen5 - Toon Thermostat - Neo CoolCam plug - Neo CoolCam PIR - FIBARO PIR - Heiman Smart Smoke Senso - Neo CoolCam Leakage Detector - BeNext Tag Reader - P1 and S0 USB - many Mi-Light lights - KAKU switches
glsf91
Posts: 58
Joined: Tuesday 14 November 2017 21:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post 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.
curious
Posts: 132
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

Re: notifications to chromecast

Post 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
Last edited by curious on Friday 23 March 2018 16:00, edited 1 time in total.
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: notifications to chromecast

Post 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?
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
freakshock
Posts: 64
Joined: Friday 14 April 2017 13:39
Target OS: NAS (Synology & others)
Domoticz version:
Location: The Netherlands
Contact:

Re: notifications to chromecast

Post 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?
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: notifications to chromecast

Post 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.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: notifications to chromecast

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest