notifications to chromecast Topic is solved

Alexa, Google Home and Siri
curious
Posts: 125
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

notifications to chromecast

Post by curious » Tuesday 13 March 2018 21:59

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: 125
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

Re: notifications to chromecast

Post by curious » Thursday 15 March 2018 23:48

Solved...works fine :)

Just forgot to enable the custom/http action in notification settings

User avatar
sincze
Posts: 911
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: notifications to chromecast

Post by sincze » Sunday 18 March 2018 19:21

Haha nice, I added the NS jingle as jingle1 and after that the message. :lol: hilarious.
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

glsf91
Posts: 36
Joined: Tuesday 14 November 2017 22:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post by glsf91 » Sunday 18 March 2018 22:35

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=b98x9xlfs54ws4k0wc0o8g4gwc0w8ss&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.

User avatar
sincze
Posts: 911
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: notifications to chromecast

Post by sincze » Sunday 18 March 2018 22:38

Pretty nice. Let me try that as well. Tnx for sharing.
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

User avatar
sincze
Posts: 911
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: notifications to chromecast

Post by sincze » Sunday 18 March 2018 22:57

haha great stuff. The modified script works like a charm.
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

glsf91
Posts: 36
Joined: Tuesday 14 November 2017 22:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post by glsf91 » Monday 19 March 2018 17:01

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: 75
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 » Tuesday 20 March 2018 22:19

Can someone tell me if this is possible to achieve on Synology? If so, how? :?:

User avatar
sincze
Posts: 911
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: notifications to chromecast

Post by sincze » Tuesday 20 March 2018 22:36

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.
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

ropske
Posts: 311
Joined: Tuesday 12 August 2014 5:37
Target OS: Raspberry Pi
Domoticz version: V3_8394
Location: Rumbeke,Belgium
Contact:

Re: notifications to chromecast

Post by ropske » Tuesday 20 March 2018 22:56

to what device are you sending this? :oops:

User avatar
sincze
Posts: 911
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: notifications to chromecast

Post by sincze » Wednesday 21 March 2018 11:06

ropske wrote:
Tuesday 20 March 2018 22:56
to what device are you sending this? :oops:
At this moment to my Google Home
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

glsf91
Posts: 36
Joined: Tuesday 14 November 2017 22:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post by glsf91 » Wednesday 21 March 2018 19:19

ropske wrote:
Tuesday 20 March 2018 22:56
to what device are you sending this? :oops:
I use Chromecast audio.

User avatar
sincze
Posts: 911
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: notifications to chromecast

Post by sincze » Wednesday 21 March 2018 20: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 :)
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

User avatar
gijsje
Posts: 146
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 » Wednesday 21 March 2018 21:12

freakshock wrote:
Tuesday 20 March 2018 22: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: 36
Joined: Tuesday 14 November 2017 22:56
Target OS: Linux
Domoticz version:
Contact:

Re: notifications to chromecast

Post by glsf91 » Thursday 22 March 2018 21:03

gijsje wrote:
Wednesday 21 March 2018 21:12
freakshock wrote:
Tuesday 20 March 2018 22: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: 125
Joined: Saturday 02 April 2016 19:38
Target OS: -
Domoticz version:
Contact:

Re: notifications to chromecast

Post by curious » Thursday 22 March 2018 22: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
Last edited by curious on Friday 23 March 2018 17:00, edited 1 time in total.

User avatar
DewGew
Posts: 204
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi
Domoticz version: V3.8799
Location: Sweden
Contact:

Re: notifications to chromecast

Post by DewGew » Friday 23 March 2018 8:01

sincze wrote:
Wednesday 21 March 2018 20: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 2B - domoticz - Aeon Labs Z-Stick GEN5 - RFlink gateway
NanoPi NEO-air - domoticz - REGO6XX interface

freakshock
Posts: 75
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 » Monday 26 March 2018 20:00

glsf91 wrote:
Thursday 22 March 2018 21:03
gijsje wrote:
Wednesday 21 March 2018 21:12
freakshock wrote:
Tuesday 20 March 2018 22: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: 911
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: notifications to chromecast

Post by sincze » Saturday 28 April 2018 16:54

DewGew wrote:
Friday 23 March 2018 8:01
sincze wrote:
Wednesday 21 March 2018 20: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.
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

freijn
Posts: 299
Joined: Friday 23 December 2016 17:40
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands Purmerend
Contact:

Re: notifications to chromecast

Post by freijn » Saturday 28 April 2018 19:53

curious wrote:
Thursday 22 March 2018 22: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

Locked

Who is online

Users browsing this forum: No registered users and 3 guests