home-assistant.io/source/_integrations/google_sheets.markdown
Allen Porter b6dc520ae1
Update google calendar instructions to recommend Web Auth (#29792)
* Update google calendar instructions to recommend Web Auth

* Update source/_integrations/google.markdown

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-11-11 11:08:55 -08:00

3.0 KiB

title, description, ha_category, ha_iot_class, ha_release, ha_config_flow, ha_domain, ha_codeowners, ha_integration_type, google_dev_console_link, api, api_link, api2, api2_link
title description ha_category ha_iot_class ha_release ha_config_flow ha_domain ha_codeowners ha_integration_type google_dev_console_link api api_link api2 api2_link
Google Sheets Instructions on how to use Google Sheets in Home Assistant.
Utility
Cloud Polling 2022.10 true google_sheets
@tkdrob
service https://console.developers.google.com/start/api?id=drive Google Drive API https://console.developers.google.com/start/api?id=drive Google Sheets API https://console.cloud.google.com/apis/enableflow?apiid=sheets.googleapis.com

The Google Sheets integration allows you to connect your Google Drive to Home Assistant. The integration adds a service to allow you to append rows to a Sheets document. The idea is that you can store data on there for further processing. When you set up a config entry, your drive will have a new sheet called Home Assistant. You can then rename this to whatever you like.

Note: The integration currently only has access to that one document that is created during setup.

Prerequisites

You need to configure developer credentials to allow Home Assistant to access your Google Account. These credentials are the same as the ones for Nest, YouTube, and Google Mail. These are not the same as Device Auth credentials previously recommended for Google Calendar.

{% include integrations/google_client_secret.md %}

{% include integrations/config_flow.md %}

{% include integrations/google_oauth.md %}

Troubleshooting

If you have an error with your credentials you can delete them in the Application Credentials user interface.

Video tutorial

This video tutorial explains how to set up the Google Sheets integration and how you can add data from Home Assistant to a Google Sheet.

Service google_sheets.append_sheet

You can use the service google_sheets.append_sheet to add a row of data to the Sheets document created at setup.

{% details "Create Event Service details" %}

Service data attribute Optional Description Example
config_entry no Config entry to use.
worksheet yes Name of the worksheet. Defaults to the first one in the document. Sheet1
data no Data to be appended to the worksheet. This puts the data on a new row, one value per column. {"hello": world, "cool": True, "count": 5}

{% raw %}

# Example service call
service: google_sheets.append_sheet
data:
  config_entry: 1b4a46c6cba0677bbfb5a8c53e8618b0
  worksheet: "Car Charging"
  data:
    Date: "{{ now().strftime('%-d-%b-%y') }}"
    KWh: "{{ states('input_number.car_charging_kwh')|float(0) }}"
    Cost: "{{ states('input_number.car_charging_cost')|float(0) }}"

{% endraw %}

{% enddetails %}