Spoken Notifications Google Home (Mini/Nest/Chromecast etc) Topic is solved

Alexa, Google Home and Siri

Moderator: leecollings

User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Spoken Notifications Google Home (Mini/Nest/Chromecast etc)

Post by QNTL »

Okay, Okay, I know, there is a lot on this forum already, but I've tried a few things and they don't seem to work.

Once opun a time, there were two plugins:
https://github.com/Tsjippy/ChromecastPlugin and https://github.com/dnpwwo/Domoticz-Google-Plugin.

I also found this post viewtopic.php?t=22610.

I've done my fair share of digging, so I'm just asking the question now:

Is there a way, in 2023, to let Domoticz speak a notification over a Google Home device?
If so, is there anyone who can help me with this?


I've installed the Google Plugin, but it results in:
Spoiler: show

Code: Select all

2023-01-01 18:30:16.573 Error: Google: (GoogleDevs) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Domoticz-Google-Plugin/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2023-01-01 18:30:16.575 Error: Google: Traceback (most recent call last):
2023-01-01 18:30:16.575 Error: Google: File "/home/pi/domoticz/plugins/Domoticz-Google-Plugin/plugin.py", line 121, in <module>
2023-01-01 18:30:16.575 Error: Google: Apps={ 'Backdrop':Consts.APP_BACKDROP, 'Spotify':Consts.APP_SPOTIFY, 'Netflix':'CA5E8412', 'Youtube':Consts.APP_YOUTUBE, 'Other':'' }
2023-01-01 18:30:16.576 Error: Google: AttributeError: module 'pychromecast.config' has no attribute 'APP_SPOTIFY'
I am not that good (read, not good at all) in scripting, but I can follow instructions very well :lol:
And if the answer is no, then I've to accept that. What would be a good alternative (was looking to the IKEA speakers as well).

Oh and since it is the first day of the year: HAPPY NEW YEAR :mrgreen:
Last edited by QNTL on Thursday 05 January 2023 22:05, edited 1 time in total.
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

Hello @QNTL,

Happy New Year.

Can you first explain, what you want to do with this combination of Google-Domoticz?
How do you expect it to work?

Regards
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

Hi,

I have already set up my devices (through HomeBridge) so I can control my devices with speech.
But it is a one way street.
What I want is my Home mini telling me when a device is turned off.

So either a native support in Domoticz Notifications where I can choose my Google Devices (With the Domoticz-Google-Plugin this was suppose to work) or a mp3 file that gets played when something happnes (e.g. the doorbell gets pressed, and there is a script that plays a certain file).

In the previous entries of the github pages I added, the things I want seem to work, but since there were no updates, and it doesn't work for me, I made this entry.

Thanks in advance!
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: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by DewGew »

Dzga has this function built in viewtopic.php?t=31869 but its more complex setup

You can also try CATT https://github.com/skorokithakis/catt
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

Hi,

When posted this thread, I stumbled upon DZGA as well, I'll look into it.

CATT seems interesting for a lot of others reasons as well, but I don't see my exact wishes being fulfilled with this (I've only checked for 2 minutes since I'm working).

I'll check both options and will report back!
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

Hi @QNTL,

As you have already solved the challenge to operate Domoticz switches with speech from a Google Home device, the only wish is that , if you operate a switch in Domoticz, you will receive a spoken notification in a predefined Google Home device.

Several options exist.

1. Configure something like DZGA or use Node-RED with either SmartNora or "node-red-contrib-google-smarthome"
- DZGA: https://github.com/DewGew/Domoticz-Google-Assistant
- SmartNora: https://smart-nora.eu
- node-red-contrib-google-smarthome: https://flows.nodered.org/node/node-red ... -smarthome

DZGA and Node-RED Google SmartHome both need a configuration setup in Google Actions and are the most complex solution as presented here.
They can do much more than only sending notifications.

SmartNora is a paid service if you want to control more than 5 devices.

In all cases the notification is a fixed text for some devices:

See: https://developers.home.google.com/clou ... ifications

2. Use CATT (Cast all the things)
If you define a text (and you can create as many as you wish) and convert these to a mp3 or something similar, you can try to send that to your Google device with e.g. a Domoticz script.

However I never tested that, I only use CATT to display some webpages URL's

3. Use Node-RED and activate a Google Cast or Notify node:

- https://flows.nodered.org/node/node-red-contrib-cast
- https://flows.nodered.org/node/node-red-contrib-castv2
- https://flows.nodered.org/node/node-red ... ome-notify

I have used the first option successfully.

I believe you have now enough options to choose from.
Let us know, if you a choice and need some support with Node-RED.

Regards
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

Hello again,

Such great help already!
I think, due the more complex setup for node-red, I want to try with CATT first.
Since you already have a set up to cast a webpage, can you share that script? What I'm wondering is how CATT will see my Google devices.
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

FireWizard wrote: Monday 02 January 2023 14:23
2. Use CATT (Cast all the things)
If you define a text (and you can create as many as you wish) and convert these to a mp3 or something similar, you can try to send that to your Google device with e.g. a Domoticz script.
So, as CATT as relative easy to set up, I've come a long way already.
When I'm in my Pi Terminal, I can execute the script:

Code: Select all

catt -d, --device Kantoor cast /home/pi/Music/file.mp3 
First a little blink from my home mini, and than the soundfile, which I'll change to a spoken txt mp3 later on.

But when I'm trying to run it from Domoticz I get an error:

Code: Select all

2023-01-02 21:58:04.153 Error: Error executing script command (/home/pi/domoticz/scripts/file.sh). returned: 32512
I have this scipt as an 'on-action' of my test devices in Domoticz.

Code: Select all

#!/bin/bash

catt -d, --device Kantoor cast /home/pi/Music/file.mp3 

stop
I've made it an executable (chmod +x file.sh
I've granted all the rights (chmod 777 file.sh)

But the error persist. I've searched already for solutions, but haven't found one clear answer yet.
Shouldn't I use '.py' instead of '.sh' ? Asking this because the founder of CATT has an example where the script ends with '.py'.

Girlfriend is mad because she wants me to go to sleep, so tomorrow is anonther day! :lol:
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

Hi, @QNTL,

Can you try to run catt with the full path.
Like /path/to/catt/catt -d etc.

Regards
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

FireWizard wrote: Monday 02 January 2023 23:45 Hi, @QNTL,

Can you try to run catt with the full path.
Like /path/to/catt/catt -d etc.

Regards
Hi again,

Code: Select all

~/.local/bin/catt -d, --device Kantoor cast /home/pi/Music/file.mp3 

Code: Select all

/home/pi/.local/bin/catt -d, --device Kantoor cast /home/pi/Music/file.mp3 

The lines above don't work neither.
The line does work if ran from the terminal.
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

Hi @QNTL

How does your configuration of the switch look like.
Can you present a screenshot?

For a similar issue, see:viewtopic.php?t=19362
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

FireWizard wrote: Tuesday 03 January 2023 21:05 Hi @QNTL

How does your configuration of the switch look like.
Can you present a screenshot?

For a similar issue, see:viewtopic.php?t=19362
For now it is just a simple 'test' button with the script running with the 'on' command'

Image

Tried it with the full path of the script as well. So /home/pi/domoticz/scripts/file.sh.

I''ll take a look at the other post.
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

So the problem changed.
I don't know if it is for the good or it is worse right now.

Code: Select all

2023-01-03 21:29:06.937 Error: Error executing script command (/home/pi/domoticz/scripts/file.sh). returned: 256
The script now is as follows:

Code: Select all

#!/bin/sh

/home/pi/.local/bin/catt -d, --device Kantoor cast /home/pi/Music/file.mp3

Note that i tried #!/bin/sh instead of #!/bin/bash
Interesting result.

When using #!/bin/bash : The speaker makes a little sound before playing the file (bleep-bleep)
When using #!/bin/sh : The speaker immediately plays the file.

Of course I want to use the second one :D
But problem still persist. No succes getting it done from Domoticz.
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

@QNTL

What is the user Domoticz is running? Is it pi or is it root? Or anything else?

Try to run it as sudo

Code: Select all

#!/bin/sh

sudo /home/pi/.local/bin/catt -d, --device Kantoor cast /home/pi/Music/file.mp3
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

FireWizard wrote: Tuesday 03 January 2023 22:06 @QNTL

What is the user Domoticz is running? Is it pi or is it root? Or anything else?

Try to run it as sudo

Code: Select all

#!/bin/sh

sudo /home/pi/.local/bin/catt -d, --device Kantoor cast /home/pi/Music/file.mp3
As far as I know it runs it as 'pi' . Is there any way of checking it? It is installed in /home/pi/domoticz.

Running sudo doesn't change it. It only results in not being able to run it in the terminal window
Spoiler: show

Code: Select all

Traceback (most recent call last):
  File "/home/pi/.local/bin/catt", line 6, in <module>
    from catt.cli import main
ModuleNotFoundError: No module named 'catt'
Found something else:
Read somewhere to put ' &' after the action in Domoticz.
Or 'exit 0' at the end of the script.

Well, Domoticz doesn't give an error when I do that (so no 32512 nor 256) but it doesn't play anything. So the script seems to run, but actually doesn't.
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

@QNTL

Someone solved a similar issue with 2 scripts (This concerns a doorbell):
I did 2 different things,

Making a start script, so domoticz executed the scripts and thinks it's done immediately, (ending command with '&')

So my script doorbell.sh get executed by doorbell-start.sh
Doorbell.sh got sudo permissions
Doorbell-start.sh has user permissions
And start the doorbell.sh script with a 'sudo bash' command from doorbell-start.sh script.
I do believe that it is a user issue somewhere.

Regards
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

Okay, so I figured the script had to look something like this:

Code: Select all

#!/bin/bash (or /sh)

/home/pi/domoticz/scripts/file.sh

So it runs this scripts

Code: Select all

#!/bin/sh

sudo /home/pi/.local/bin/catt -d, --device Kantoor cast /home/pi/Music/file.mp3
Again, from the terminal no problem whatsoever.
Can you help me dive in the possible 'user issue'.
Where can I see as which user Domoticz opperates?

By the way, this is not the only script I'm using. I've have a doorbel that sends me a snapshots through Telegram, whichs works perfect with the 'on' action.
Maybe you can find something that works here, that I need in the CATT script to work.
Spoiler: show

Code: Select all

#!/bin/sh

SnapFile="/home/pi/domoticz/scripts/camera_/Deurbel.jpg"
#VideoLenght=5
WaitTime=10
User="admin"
Password="xxxx"
rtspUrl="rtsp://xxxxx"
ChatID="xxxxx" 
TelegramAPIToken="xxx" 

#ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
ffmpeg -loglevel fatal -i $rtspUrl -vframes 1 -r 1 $SnapFile
curl -s -F chat_id=$ChatID -F photo="@$SnapFile" -F caption="Er saat iemand voor de deur" 
https://api.$telegram.org/bot$TelegramAPIToken/sendPhoto

rm$SnapFile
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

@QNTL,

Use Linux command:

Code: Select all

ls -l /home/pi/domoticz/domoticz
You will get something similar as:

Code: Select all

-rwxr-xr-x 1 pi pi 13854844 Jan  1 11:42 /home/pi/domoticz/domoticz
In this case Domoticz runs under the user "pi"
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by QNTL »

FireWizard wrote: Wednesday 04 January 2023 21:14

Code: Select all

-rwxr-xr-x 1 pi pi 13854844 Jan  1 11:42 /home/pi/domoticz/domoticz
In this case Domoticz runs under the user "pi"

Got exactly the same result, so indeed it runs as pi.
On the domoticz wiki it says:
Spoiler: show
You can run a perl, python, bash etc. script from the 'On Action:' or 'Off Action:' parameter of a switch. As an example:

script://coolscript.pl (or .py / .sh)
where 'coolscript.pl' is a perl file in the '/home/pi/domoticz/scripts' folder Be aware, however, that Domoticz will wait for this script to finish executing before it continues. This means that if there are any long loops with e.g. sleep statements in your script then your Domoticz event queue will be severely delayed. A simple way to get around this is to wrap the call to the perl/python script inside a bash script that uses the '&' notation to spawn off a subprocess to run the script and return immediately (with bash you can do this directly with " > /dev/null 2>&1 &" at the end of your call so there's no need for an intermediate bash script).

In your scripts directory, create a file called exec.sh with the following content:

Code: Select all

#! /bin/sh
/usr/bin/perl /home/pi/domoticz/scripts/$1.pl $2 $3 > /dev/null 2>&1 &
or, for python

Code: Select all

#! /bin/sh
/usr/bin/python /home/pi/domoticz/scripts/$1.py $2 $3 > /dev/null 2>&1 &
You can now use the following syntax to call up the actual perl/python script as follows:

Code: Select all

script://exec.sh coolscript
This way, control is immediately returned to Domoticz while your perl/python script coolscript runs in the background. It can still interact with Domoticz using JSON calls as per usual, it's just running quietly.
I tried this as well, but no luck.
The search continues..
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Spoken Notifications Goolge Home (Mini/Nest/Chromecast etc)

Post by FireWizard »

@QNTL<

What, if you create an intermediate script, like

Code: Select all

#!/bin/sh
/home/pi/domoticz/scripts/catt_start > /dev/null 2>&1 &
And another file, e.g catt_start with the contents of

Code: Select all

#!/bin/sh

/home/pi/.local/bin/catt -d, --device Kantoor cast /home/pi/Music/file.mp3
Or something similar with sudo

Can you send a screenshot of your Switch configuration?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests