Library for the Google Nest SDM API
Project description
python-google-nest-sdm
This is a library for Google Nest Device Access using the Smart Device Management API.
Usage
This can be used with the sandbox which requires Registration, accepting terms and a fee.
You'll want to following the Get Started guides for setup including steps in the google cloud console. Overall, this is fairly complicated with many steps that are easy to get wrong. It is likely worth it to make sure you can get the API working using their supplied curl commands with your account before attempting to use this library.
Structure
This API was designed for use in Home Assistant following the advice in Building a Python Library for an API.
If you are integrating this from outside Home Assistant, you'll need to create your own oauth integration and token refresh mechanism and tooling.
Fetching Data
This is an example to use the command line tool to access the API:
PROJECT_ID="some-project-id"
CLIENT_ID="some-client-id"
CLIENT_SECRET="some-client-secret"
# Initial call will ask you to authorize OAuth2 then cache the token
google_nest --project_id="${PROJECT_ID}" --client_id="${CLIENT_ID}" --client_secret="${CLIENT_SECRET}" list_structures
# Subsequent calls only need the project id
google_nest --project_id="${PROJECT_ID}" get_device "some-device-id"
google_nest --project_id="${PROJECT_ID}" set_mode COOL
google_nest --project_id="${PROJECT_ID}" set_cool 25.0
Subscriptions
See Device Access: Getting Started: Subscribe to Events for documentation on how to create a pull subscription.
You can create the subscription to use with the tool with these steps:
- Create the topic:
- Visit the Device Access Console
- Select a project
- Enable Pub/Sub and note the full
topic
based on theproject_id
- Create the subscriber:
- Visit Google Cloud Platform: Pub/Sub: Subscriptions
- Create a subscriber
- Enter the
Topic Name
- Create a
Subscription Name
, e.g. "project-id-python" which is yoursubscriber_id
This is an example to run the command line tool to subscribe:
PROJECT_ID="some-project-id"
SUBSCRIPTION_ID="projects/some-id/subscriptions/enterprise-some-project-id-python-google-nest"
google_nest --project_id="${PROJECT_ID}" subscribe ${SUBSCRIPTION_ID}
Development
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -e .
$ pip3 install -r requirements.txt
# Running tests
$ pytest
# Running tests w/ Code Coverage
$ pytest --cov=google_nest_sdm tests/ --cov-report=term-missing
# Formatting and linting
$ pre-commit run --all-files
Funding and Support
If you are interested in donating money to this effort, instead send a donation to Black Girls Code which is a great organization growing the next generation of software engineers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file google_nest_sdm-6.1.4.tar.gz
.
File metadata
- Download URL: google_nest_sdm-6.1.4.tar.gz
- Upload date:
- Size: 67.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2a1d51f88c5164b62b2bad728615339d5d878afe32e58de3e2d473329b17853 |
|
MD5 | c25532cf77b86a842bf76939e5544d58 |
|
BLAKE2b-256 | 0ee8a336ff77b00a7e29c5aa06154299cdcb45c1d3ac7c6185aff1cc8aa73bf6 |
Provenance
The following attestation bundles were made for google_nest_sdm-6.1.4.tar.gz
:
Publisher:
publish.yaml
on allenporter/python-google-nest-sdm
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
google_nest_sdm-6.1.4.tar.gz
- Subject digest:
a2a1d51f88c5164b62b2bad728615339d5d878afe32e58de3e2d473329b17853
- Sigstore transparency entry: 147192296
- Sigstore integration time:
- Predicate type:
File details
Details for the file google_nest_sdm-6.1.4-py3-none-any.whl
.
File metadata
- Download URL: google_nest_sdm-6.1.4-py3-none-any.whl
- Upload date:
- Size: 50.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e386dcd82b6085b051642970df727853e7408cd95ab2253b11404e4f1635215e |
|
MD5 | 533c05a9c28ddcaece52c6ee22f01179 |
|
BLAKE2b-256 | 026825e155aa89bb61e514f333916a144685cfe7637e9439ea0fd394a6e8dd6f |
Provenance
The following attestation bundles were made for google_nest_sdm-6.1.4-py3-none-any.whl
:
Publisher:
publish.yaml
on allenporter/python-google-nest-sdm
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
google_nest_sdm-6.1.4-py3-none-any.whl
- Subject digest:
e386dcd82b6085b051642970df727853e7408cd95ab2253b11404e4f1635215e
- Sigstore transparency entry: 147192299
- Sigstore integration time:
- Predicate type: