HomeHome AutomationGoogle Home Notifications Tutorial

Google Home Notifications Tutorial

Spoken, like a true AI! I just made my Google Home speaker even more amazing.

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 or node-red-contrib-cast

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.

The Google Home Notify node is no longer working, but you can replace it with node-red-contrib-cast for NodeRED

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!)
https://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
Profile: GHome Casting
	Event: AutoNotification Intercept [ Configuration:Event Behaviour: true
		   Notification Type: Only Created Notifications
		   Notification Apps: Inbox ]
Enter: Cast To GHome 
	A1: HTTP Post [ Server:Port:YOUR_IP_or_DNS:1880 
	Path:/Ghome 
	Data / File:
		app=%anapp
		title=%antitle
		text=%antext 
	Cookies: User Agent: Timeout:10 
	Content Type: Output File: 
	Trust Any Certificate:On ] 

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
Profile: Start GHome
	Event: AutoVoice Recognized [ Configuration:Easy Commands: read notifications ]
Enter: Start GHome Notifications 
	A1: Profile Status [ Name:GHome Casting Set:On ] 
	A2: AutoAppsHub SendCommand [ Configuration:Command: 
		NOTIFICATION=:=All notifications forwarded=:=All push notifications  are sent  to the smart speaker=:=GoogleHome=:=#0B974C=:=0=:=GoogleHome=:=GoogleHome=:=Stop=:=GHome Pause=:=Stop All=:=GHome StopAll
		Timeout (Seconds):60 ] 

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
Profile: Stop GHome
	Event: AutoVoice Recognized [ Configuration:Easy Commands: stop notifications ]
Profile: GHome AN Command 
	Event: AutoApps Command [ Configuration:Command Filter: ghome ]
Enter: Stop GHome notifications 
	A1: If [ %aamessage ~R pause | %avcomm ~ stop notifications ]
	A2: AutoNotification Cancel [ Configuration:Id: googlehome Timeout (Seconds):0 ] 
	A3: Profile Status [ Name:GHome Casting Set:Off ] 
	A4: Flash [ Text:Mobile Notifications Disabled Long:Off ] 
	A5: End If 
	
	A6: If [ %aamessage ~R stopall ]
	A7: AutoNotification Cancel [ Configuration:Id: googlehome Timeout (Seconds):0 ] 
	A8: HTTP Post [ Server:Port:youtip:1880 Path:/g/ 
		Data / File:ghomenotification=off Cookies: 
		User Agent: Timeout:10 Content Type: Output File: 
		Trust Any Certificate:On ] 
	A9: End If 
	
	---bonus---
	A10: If [ %aamessage ~R enableall ]
	A11: AutoNotification Cancel [ Configuration:Id: googlehome Timeout (Seconds):0 ] 
	A12: HTTP Post [ Server:Port:youtip:1880 Path:/g/ 
		 Data / File:ghomenotification=on Cookies: 
		 User Agent: Timeout:10 Content Type: Output File: 
		 Trust Any Certificate:On ] 
	A13: End If 

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:

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

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

0
To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

0
Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

0
Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

DIY Smart Washing Machine – for about 15 bucks!

0
Learn how to add washing machine notifications to your Google Home on the cheap

Sonoff Zigbee Bridge – review

0
Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

Smart Home

Remotes aren’t done with us yet: SwitchBot Remote

0
If you hate having 20 remotes hidden in your sofa, or your parents despise talking to Alexa to turn the lights on - SwitchBot Universal Remote is here to deal with all this!

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?