Improved Google Nest Events for Home Assistant
Table of Contents
Introduction
Google Home scripted automations can provide a bridge to Home Assistant for Nest devices. Home Assistant has the Google Nest integration already, but device feature support can be limited, and the SDM API it uses can be slower and rate limited. A combination of Home Assistant Cloud and some simple scripted automations in Google Home allow your Google Assistant device to relay messages locally to your Home Assistant installation with a faster response time (in my experience), at a higher resolution, and with more features exposed.
Here’s a list of events that I’m receiving from Google Home this way that the Google Nest integration or SDM does not provide:
- Animal detected
- Unfamiliar face detected
- Familiar face detected
- Package detected
- Vehicle detected
Home Assistant Helper
The first thing to setup is a set of entities to expose to Google Assistant that can be activated by a Google Home routine. I use Input Button helpers, one for each event. Input button helpers will be exposed as a scene to Google Assistant. You could use another helper type, but this is a stateless interaction and a button is as simple as it gets.
For this example, I want to know when my Nest doorbell detects a package, something the Google Nest integration does not support. We’ll create an input button helper, either through the UI or in configuration.yaml
like this:
input_button:
front_door_package_detection:
name: Front Door Package Detection
Before leaving Home Assistant, we’ll want to expose this button to Google Assistant by going to Settings > Voice Assistants
, or by going to Voice assistants > Expose: Google Assistant
from the helper dialog. You can find more details at Exposing entities to Assist.
Google Home Scripted Automation
Over in Google Home, switch to the Automations page and create the following scripted automation:
metadata:
name: Front Door Package Detection
description: Scripted automation
automations:
starters:
- type: device.event.PackageDetection
device: Front door doorbell - Front door
actions:
- type: device.command.ActivateScene
activate: true
devices: Front Door Package Detection
That’s it. It simply presses the button (activates the scene as far as Google knows) every time a package is detected by the doorbell camera.
Note: You may have to opt-in to
Public preview
to get access to the script editor.
Home Assistant Automation
Finally, back in Home Assistant we can setup an automation with the following trigger:
trigger: state
entity_id:
- input_button.front_door_package_detection
to: null
The above yaml trigger would be represented as When Front Door Package Detection changes to any state
in the UI. Now whenever Google Home presses the button for a package detection, the state of input_button.front_door_package_detection
will change and the automation will trigger.
Doing all this can still be useful for events that are already provided by the Google Nest integration. In my experience, events using this method will often arrive a couple seconds sooner. I do not consider it a replacement for the integration in these cases however. It could break or change behavior at any time. What I do is let the events from this method race with events from the integration. My automations will have triggers for both:
triggers:
- device_id: abc123 # this will be your unique device_id
domain: nest
type: camera_person
trigger: device
- trigger: state
entity_id:
- input_button.backyard_person_detection
to: null
Because both events arrive at nearly the same time, the automation may need to use debouncing of some form or another. Some examples of debouncing in a Home Assistant automation are using a timer helper or simply following your actions with a wait combined with the single
automation mode, although the later method will result in log warnings. Debouncing may also be necessary because the frequency of events using this method is much higher than events coming from the integration.
Results
Events from scripted automations can be a couple seconds faster than the SDM API used by the Google Nest integration. Here’s an example from the automation logbook:
Front Door Activity triggered by state of Front Door Person Detection
6:38:57 AM - 4 hours ago
Front Door Activity triggered by event 'nest_event'
6:38:59 AM - 4 hours ago
Front Door Activity triggered by state of Front Door Person Detection
6:39:02 AM - 4 hours ago
The first event, sent by the scripted automation, arrives a couple seconds before the Google Nest integration event. In this example, the integration never even sends a matching event for the second detection. This is most likely due to rate limiting by the SDM API.
The scripted automation events are sent locally, at least between my Google Assistant and Home Assistant devices. It looks like this in the global logbook:
Google Assistant sent command ActivateScene (via local)
6:38:57 AM - 4 hours ago - Home Assistant Cloud
Google Assistant sent command ActivateScene (via local)
6:39:02 AM - 4 hours ago - Home Assistant Cloud
An additional bonus is that these events fire even when device notifications are turned off. For some of my Nest devices, I have them set to only send me notifications when we are not home. This seems to also suppress any events for that device coming from the Google Nest integration or the SDM API, preventing me from silently using them for automations while home. The additional events from the Google Home scripted automations have been coming through regardless of our home presence or notification settings.
Conclusion
I think this a compelling addition to Home Assistant installations using Nest devices. I only recommend doing this in a supplemental way - I would consider it volatile and secondary when possible. I outline some advantages and disadvantages to consider below:
Advantages:
- Events sent even if phone notifications turned off for the device
- Higher event resolution
- Faster event delivery
- Supports events like package/animal/unfamiliar/familiar that the Google Nest integration does not
Disadvantages:
- Maintenance across multiple platforms
- Automations may require debouncing