Hello! I am trying to pull data from Google Sheets and display it in a Dashboard. For this, I am trying to set up a new restful integration to the Google Sheets api v4. However, I really don’t understand how the restful integration works, especially with Google’s OAuth2 authentication, maybe someone could help? Here’s what I have in my configuration.yaml so far:
I’m trying to do what you’re doing as well! This post might contain what we need, but haven’t attempted to make this work for OAuth with Google Sheets API yet
I wondered if I can solve this challenge by creating a “python sensor” - a python script would connect to the google sheet and do the authentication, extract and transform the data I need. Then simply produce the needed values and HA would pick it up as a sensor. I will post the script when I’ve had time to try it out, or feel free to do the same if you get to it first.
My solution for analyzing scv file data. I have a google spreadsheet with access control data. I upload data in csv format, separated by commas, to the home as server. Next, I search for data in the csv file using input_text.data_search. The command line sensor searches for a term with the required data and places the result in the attributes. Perhaps this will be useful to someone.
This command works in the terminal if the source table is open for viewing.
If closed, you need to add an API access key to the link. Haven’t tried it yet.
Something like that:
You can also add feedback. Write a script in Google sheets (GAS). Which will monitor changes in the table and send a post request to the Home Assistant server. This way Home Assistant will understand whether database changes have occurred. You can write some kind of automation to re-upload csv when updating information in table cells.
Sorry for my English, I’m Russian.
For the OAuth2 setup, you’ll need to create credentials in the Google Cloud Console. Make sure to set the redirect URI correctly, or it won’t work. The rest integration can support OAuth2, but you might find using a library like google-auth or google-api-python-client in Python simplifies the process, especially for handling the authentication flow.When I set up something similar, I hit a wall with the OAuth part too. I found My Excel Online super helpful for brushing up on how to format data before pulling it into my project. To debug, check your logs for any error messages, and you can also use Postman to test the API calls independently. It can really help you figure out if the issue lies with the code or the API itself.