home-assistant.io/source/_components/google_pubsub.markdown
Franck Nijhof c464056402
Making our website faster, cleaner and prettier (#9853)
* 🔥 Removes octopress.js

* 🔥 Removes use of root_url var

* 🔥 Removes Octopress generator reference from feed

* 🔥 Removes delicious support

* 🔥 Removes support for Pinboard

* 🔥 Removes support for Disqus

* 🔥 Removes support for Google Plus

* ↩️ Migrate custom after_footer to default template

* ↩️ Migrate custom footer to default template

* ↩️ Migrate custom header to default template

* 🔥 Removes unused template files

* 🚀 Places time to read directly in post template

* 🚀 Removes unneeded capture from archive_post.html template

* 🔥 🚀 Removes unused, but heaving sorting call in component page

* 🚀 Merged javascripts into a single file

* 🔥 Removes more uses of root_url

* 🚀 Removal of unneeded captures from head

* 🔥 🚀 Removal of expensive liquid HTML compressor

* 🔥 Removes unneeded templates

* 🚀 Replaces kramdown with GitHub's CommonMark 🚀

* 💄 Adds Prism code syntax highlighting

*  Adds support for redirect in Netlify

* ↩️ 🔥 Let Netlify handle all developer doc redirects

* ✏️ Fixes typo in redirects file: Netify -> Netlify

* 🔥 Removes unused .themes folder

* 🔥 Removes unused aside.html template

* 🔥 Removes Disqus config leftover

* 🔥 Removes rouge highlighter config

* 🔥 Removes Octopress 🎉

* 💄 Adjust code block font size and adds soft wraps

* 💄 Adds styling for inline code blocks

* 💄 Improve styling of note/warning/info boxes + div support

* 🔨 Rewrites all note/warning/info boxes
2019-07-15 22:17:54 +02:00

3.2 KiB

title, description, logo, ha_category, ha_release
title description logo ha_category ha_release
Google Pub/Sub Setup for Google Pub/Sub integration google-pubsub.png
History
0.88

The google_pubsub integration allows you to hook into the Home Assistant event bus and send events to Google Cloud Pub/Sub. The current free tier of GCP should allow you to sync about 1 event every 2 seconds on average (2 million invocations per month).

First time setup

This assumes you already have a Google Cloud project. If you don't, please create one in the Google Cloud Console

You need to create a Service Account key in the Google Cloud API Console

  • Choose a new "New Service Account", give it a name and leave the key type as JSON
  • Select the role: Pub/Sub Publisher

This will download the Service Account JSON key to your machine. Do NOT share this with anyone. Place this file in your Home Assistant config folder.

Next, create a Google Pub/Sub topic in the Google Cloud API Console. The topic name will become something like projects/project-198373/topics/topic-name. Note the last part only (the name you chose): topic-name.

Configuration

Add the following lines to your configuration.yaml file:

# Example configuration.yaml entry
google_pubsub:
  project_id: YOUR_PROJECT_ID
  topic_name: YOUR_TOPIC_NAME
  credentials_json: CREDENTIALS_FILENAME

{% configuration %} project_id: description: Project ID from the Google console (looks like words-2ab12). required: true type: string topic_name: description: The Pub/Sub relative topic name (looks like hass). required: true type: string credentials_json: description: The filename of the Google Service Account JSON file. required: true type: string filter: description: Filter domains and entities for Google Cloud Pub/Sub. required: true type: map keys: include_domains: description: List of domains to include (e.g., light). required: false type: list exclude_domains: description: List of domains to exclude (e.g., light). required: false type: list include_entities: description: List of entities to include (e.g., light.attic). required: false type: list exclude_entities: description: List of entities to include (e.g., light.attic). required: false type: list {% endconfiguration %}

Not filtering domains or entities will send every event to Google PubSub, thus hitting the free tier limit very fast. Be sure to fill in this configuration parameter or have a paid subscription for Google Cloud.

Saving the data using a Google Cloud Function

To save your data automatically to BigQuery, follow the instructions here. The current free tier of GCP should allow to store up to 10GB of data.