Google Pub/Sub

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 configuration 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.


Add the following lines to your configuration.yaml file:

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

Configuration Variables



Project ID from the Google console (looks like words-2ab12).



The Pub/Sub relative topic name (looks like hass).



The filename of the Google Service Account JSON file.



Filter domains and entities for Google Cloud Pub/Sub.



List of domains to include (e.g., light).



List of domains to exclude (e.g., light).



List of entities to include (e.g., light.attic).



List of entities to include (e.g., light.attic).

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.