A robust Python plugin for integrating Google Nest devices with Domoticz home automation system using the Smart Device Management (SDM) API. Or at least I hope it is robust. Current version still in testing.
The plugin is fairly simplistic, there is no Eco or away mode. Implemented the Temeprature readout, humidity and managing setpoint.
It is not perfect.
- Automatic token management with refresh and rotation handling
- Persistent token storage with backup recovery
- Connection retry logic with exponential backoff
- Comprehensive error handling and recovery
- Support for multiple Nest devices:
- Nest Thermostats (temperature control & monitoring)
- Temperature sensors
- Humidity sensors
- Diagnostic tools for troubleshooting connection issues
- HTTP Basic Auth support for protected Domoticz instances
- Domoticz home automation system (version 2020.1 or later)
- Python 3.7 or higher
- Google Nest device(s) activated with a Google account
- US$5 for Google Device Access registration (one-time fee)
- A Google Cloud Project with OAuth 2.0 credentials
- Go to the Device Access Console
- Accept the Terms of Service
- Pay the one-time US$5 registration fee
- Note: You must use a consumer Google Account (e.g., gmail.com) - Google Workspace accounts are not supported
-
Enable the Smart Device Management API:
- Visit Google Cloud Console
- Use the "Enable the API and get an OAuth 2.0 Client ID" button or manually enable the Smart Device Management API
- Create a new project or select an existing one
-
Create OAuth 2.0 Credentials:
- Go to APIs & Services > Credentials
- Click "Create Credentials" > "OAuth client ID"
- Select "Web application" and add the following redirect URIs:
https://www.google.comhttps://www.getpostman.com/oauth2/callbackhttp://localhost:8080/https://where your domoticz runs if exposed.com
- Save your Client ID and Client Secret
- Return to the Device Access Console
- Click "Create project"
- Enter a project name and your OAuth 2.0 Client ID
- Initially leave "Enable events" unchecked (can be enabled later)
- Save your Project ID (UUID format like
32c4c2bc-fe0d-461b-b51c-f3885afff2f0)
-
Get Authorization Code: Open this URL in your browser (replace with your values):
https://nestservices.google.com/partnerconnections/YOUR_PROJECT_ID/auth? redirect_uri=https://www.google.com& client_id=YOUR_CLIENT_ID& access_type=offline& prompt=consent& response_type=code& scope=https://www.googleapis.com/auth/sdm.service -
Get Initial Tokens: Use the included
nest_token_manager.pyscript:python3 nest_token_manager.py # Select option 1: Get new authorization # Paste the authorization code when prompted
-
Clone this repository:
cd ~/domoticz/plugins git clone https://github.com/yourusername/nest-sdm-domoticz.git Nest cd Nest
-
Install Python dependencies:
pip3 install requests psutil
-
Set up configuration: Create
client_secrets.json:{ "web": { "client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com", "client_secret": "YOUR_CLIENT_SECRET", "redirect_uris": ["http://localhost:8080/"] } } -
Restart Domoticz:
sudo systemctl restart domoticz
- Go to Setup > Hardware in Domoticz
- Add new hardware:
- Name:
Nest Thermostat(or your preference) - Type:
Google Nest SDM Plugin - Fill in:
- Client ID: Your OAuth Client ID
- Client Secret: Your OAuth Client Secret
- Refresh Token: Token from Step 4
- Enterprise ID: Numbers only from your Project ID
- Auth Username/Password: (Only if Domoticz uses Basic Auth)
- Name:
- Click "Add"
Interactive tool for token management:
- Initial OAuth authorization
- Token refresh
- API connection testing
- Token display
Usage:
python3 nest_token_manager.pyDiagnostic tool for connection issues:
- DNS resolution testing
- SSL/TLS verification
- Token validity checking
- Continuous monitoring mode
- Transport endpoint error diagnosis
Usage:
python3 nest_connection_monitor.pyThis typically indicates network connectivity issues. Run diagnostics:
python3 nest_connection_monitor.py
# Select option 3: Diagnose transport endpoint errorCommon solutions:
- Restart Domoticz:
sudo systemctl restart domoticz - Check network connectivity:
ping smartdevicemanagement.googleapis.com - Increase file descriptor limits:
ulimit -n 4096
The plugin should handle this automatically, but if issues persist:
python3 nest_token_manager.py
# Select option 2: Refresh existing tokenYour refresh token has expired or been revoked. Re-authorize:
python3 nest_token_manager.py
# Select option 1: Get new authorizationEnable debug logging in Domoticz:
- Go to Setup > Settings > Other
- Set "Debug log level" to "Normal + Status + Error + Debug"
- Check logs at:
/var/log/domoticz/domoticz.log
Nest/
βββ plugin.py # Main plugin file
βββ nest_token_manager.py # Token management utility
βββ nest_connection_monitor.py # Connection diagnostic tool
βββ client_secrets.json # OAuth credentials (create this)
βββ nest_tokens.json # Token storage (auto-created)
βββ README.md # This file
- Never commit credentials to version control
- Add these files to
.gitignore:client_secrets.jsonclient_id.jsonnest_tokens.json*.pickle
- Access tokens expire after 1 hour and are automatically refreshed
- Refresh tokens should be used within 6 months to prevent expiration
- Google Nest Device Access Documentation
- Smart Device Management API Reference
- Authorization Guide
- Supported Devices
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Test your changes thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This is an unofficial plugin and is not affiliated with, endorsed by, or connected to Google or Nest or Domoticz. Use at your own risk. No warranties but a lot of pleasure with a working integration.
- Domoticz community for the plugin framework
- Google Nest team for the SDM API
- Contributors and testers
- Issues: Please use the GitHub Issues page
- Domoticz Forum: Third Party Integrations
- Google Support: Nest Device Access Support
- Improved token refresh mechanism
- Added persistent token storage
- Enhanced error handling and recovery
- Added diagnostic tools
- Better connection retry logic
- Initial release
- Basic Nest thermostat integration
- OAuth2 authentication
Note: The Device Access registration fee is US$5 per account and is non-refundable. Each Google Account can create up to 3 Device Access projects.
For commercial use, you'll need to apply for Commercial Development which includes additional requirements and assessments.