Google Home Notifications Tutorial

Spoken, like a true AI! I just made my Google Home speaker even more amazing. I hate talking to these things. I want the smart speaker to tell me an information as I need it without any "Hey Google"! Fortunately, I got it all figured it out and now you can receive your phone, sensor or computer notifications via Google Home speaker.

Each time I say “Hey Google” I feel slightly awkward, less if no one is around, as using voice commands in public is as frowned upon as much as taking hands-free calls in the 90s. To see what exactly can you do with this setup – see the showcase piece I wrote before. It’s great to have a system that would announce all your notifications for you, especially when you can easily control when these messages are verbalised.

In the Google Home Notifications Tutorial, I’ll show you how to:

  • Send notifications to your Google Home device (mobile/PC/other)
  • Enable//disable notifications through Google Home, Mobile or Alexa
  • Toggle notifications from mobile while leaving other notifications enabled

Google Home Notifications

You are probably aware of my love for NodeRED. This setup is no different. I’m running a NodeRED server on Raspberry Pi Zero connected to my network. If you don’t have the microcontroller yet, trust me – this is going to be the best $5 spent ever! Just see my other tutorials and you will know what this combo (RPI+NodeRED) is capable of.

Setup

I’m using a Google Home node from GitHub. To install it to your Raspberry Pi run:

npm install node-red-contrib-google-home-notify

Once installed, reboot the Raspberry Pi and go to Palette Manager to install it. You will see an extra Google Home node. The node itself has to be configured, open it up and enter the IP of your Google home.  I use Fing to look up the devices on my network.

You can pass any string as a payload and within seconds, Google Home will say whatever sentenced you used for testing.

Sending Notifications

The easiest way to send data to NodeRED is via HTTP POST. This functionality is available across different programming languages and apps. To send a POST request you will need to use the following details:

[DNS_name or IP of your NodeRED]:1880
/working_directory/folder/

I decided to send the information as a JSON style data where an information is linked to a ‘key’ which holds that data. If I’m sending a push notification from my Android, I would like to include the basic information like the app issuing the notification, title and text of the notification:

app=Email app (available as msg.payload.app)
title=Season Greetings (available as msg.payload.title)
text=Have a fantastic time! (available as msg.payload.text)

Using JSON alike formatting makes it easier to convert the data into a readable string:

msg.payload = "You have a notification from"
 + msg.payload.app
 + "..."
 + "saying"
 + msg.payload.title
 + "..."
 + msg.payload.text

return msg;

The complete message would read: You have a notification from Email app … saying Season Greetings, have a fantastic time! 

In parallel to the mobile notifications which would supply the app/title/text format, I have other devices. A switch node is used to decide what type of notification is arriving (in my case if it contains msg.payload.app) and how the notification is constructed. Of course, feel free to modify the flows and the way you format your responses. I’m keeping this fairly simple.

You could also use a switch node to monitor for a specific payload, and change it entirely to the desired string. I used this quick approach for my ‘PC is online/offline‘ notification. This approach works well when you are expecting a specific message or a bool value. I have included this in my Google Home Notification flow.

Enable/Disable Google Home Notifications

Since no one wants to log in to NodeRed to toggle these on and off, I created a flow which toggles the notification. This way you can disable all the notification with a single command issued from any device. As before the information has to be submitted via HTTP POST.

The ‘Check the content of the payload‘ node can be replaced by a switch node, as all it does, it makes sure that the change node receives a boolean value (in my case this is stored as ghomenotification =on/off):

msg.payload = (msg.payload.ghomenotification == 'on') ? true : false;

return msg;

The change node enables the node inserted in our Google Home Notification flow. If that node is enabled, the notifications flow as normal, otherwise, the communication is disabled.

Lastly, the spoken feedback is issued to the Google Home node to let you know if settings have been toggled successfully. You will also notice the ON/OFF inject nodes for testing. Feel free to remove it from the example file.

Toggling Google Home Notifications

There are four ways of toggling the Google Home Notifications:

  • from Google Home
  • from Alexa
  • from PC
  • from Android device via Tasker

In addition to this, you can toggle mobile notifications separately, just in case you don’t want to have mobile notifications enabled, but you want other notifications to go through just fine. This can be done via Google Home and AutoVoice or directly from your phone.

Toggling notifications from Google Home

By far the easiest way is to use IFTTT to toggle the notifications.  Create an IFTTT applet:

If This

Use the Google Assistant service to create a custom command with a text field:

Turn the notifications $

The $ symbol will be replaced with on/off depending on your command. Add a custom reply to hear the acknowledgement.

Sure, I'm on it!
Then That

Use Webhooks skill to create an HTTP POST request. Configure the request as follows:

URL (must use http/htttps in front!)
http://YOUR_IP_or_DNS:1880/yourdirectory/
METHOD
POST
CONTENT TYPE
Application/json
BODY
{ "ghomenotification": "{{TextField}}" }

Save your applet and you can use the new custom phrase to toggle the Google Home Notifications.

Toggling notifications from Alexa

This route is much easier. Install Alexa node  – you can find the detailed instructions here. Then add a new device and name it ‘notifications’ – assign values on/off and you can toggle the notifications on/off straight away!

Connect the Alexa node directly to the ‘Compose’ response – as the value sent to the NodeRed is a boolean.

Toggling notifications from PC

I can also send (automated or not) POST request from a Windows PC using EventGhost.  Use Python action to create a POST request:

import requests 
import httplib, urllib

conn = httplib.HTTPConnection("YOUR_IP_or_DNS:1880")
conn.request("POST", "/directory/", "ghomenotification=on/off" )

You can link this action to any event, keyboard shortcut, macro etc.

Toggling notifications from an Android device with Tasker

I’m going to cover the Tasker end further on in detail, as there is more work to be done to enable the mobile notifications and the Android-specific toggle. For now, all you need to know is how to pass the HTTP POST request with Tasker.

Search for HTTP POST action in Tasker and follow the example below:

SERVER:PORT
Your_IP_or_DNS:1880
PATH:
/directory/
DATA/FILE
ghomenotifications=on/off
TRUST ANY CERT
Yes

Feel free to replace the value in the Data/File section with a variable to streamline the toggle.

Google Home Notifications from an Android device

The last part of the tutorial will focus on Tasker and the ability to send the notifications to Google Home. You will be able to control the notifications from the Android device via notification, as well as via AutoVoice command issued via Google Home.

The project consists of 3 tasks:

Cast to Google Home/Ghome Casting

TASKER PROFILE: GHome Casting
I encountered some issues with AutoCast, mainly when the screen was locked. I opted out to use the HTTP POST instead. The system works well. You can pass as much data as you want, but remember that single response is limited to 200 characters from NodeRed to Google Home. The POST request should be configured like this:

SERVER:PORT
Your_IP_or_DNS:1880 
PATH: 
/directory/ 
DATA/FILE 
app=%anapp
title=%antitle
text=%antext
TRUST ANY CERT Yes

You can pick the data you want to send to your speaker. For the sake of this example, I’m focusing on the name of the app which has issued the notification, the title of the notification and the text of the notification.  These values will be formatted as a JSON object and processed in the NodeRED.

The notification is intercepted by the AutoNotification plugin, and the values are sent via local variables to the POST action. You can limit what notifications you wish to monitor (just text messages but not facebook updates etc) and what fields are populated.

Start Ghome/Start GHome Notifications

TASKER PROFILE: Start Ghome

When AutoVoice command ‘read notifications’ is issued to Google Home or Google Assistant using “Hey, Google, tell AutoVoice to read notifications” the casting profile is enabled and a notification is displayed.

I used the near-perfect autonotifications system to create one quickly with the following format:

NOTIFICATION=:=All notifications forwarded=:=All push notifications  are sent  to the smart speaker=:=GoogleHome=:=#0B974C=:=0=:=GoogleHome=:=GoogleHome=:=Stop=:=GHome Pause=:=GHome StopAll

The notification contains information about the toggle and 2 buttons to stop relaying mobile notifications and stop relaying all notifications. These buttons will trigger respective AutoApps commands.




Stop Ghome/GHome AN Command/ Stop Ghome Notifications

TASKER PROFILE: Stop Ghome/Ghome AN Commands

Lastly, I needed a profile that will stop the service on mobile, stop the Google Home Notifications and respond to the buttons from the notification created above.

The buttons issue AutoApps command (GHome pause/stopall/enableall*) which based on the value is processed in the task linked to this profile. The first IF (A1) condition handles the AutoVoice and AutoApp command. I used Profile Status action to turn the notifications off.

The second and the third condition handle the general toggle (*enableall is added as a bonus but not implemented in any way). This way you can disable the Google Home Notifications from the AutoNotificaiton directly.

Conclusion

I’m aware that this is a serious piece to read through. It took me hours to get all of these things to work and I did my best to explain it to you in details. Obviously feel free to edit anything you wish. I used the following plugins:

AutoVoice Pro Unlock
Price: $2.99
AutoApps
Price: Free+

Please note that the Tasker Files will require the Near-Perfect Notification Project to work without further edits.

Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.
SHARE