A smart home monitoring solution that integrates Enphase Envoy solar power data with Hubitat Elevation and includes authentication tools for accessing local Envoy systems.
This project provides multiple tools for monitoring Enphase Envoy solar production systems:
- Hubitat Driver - A comprehensive Groovy driver for Hubitat Elevation that provides real-time solar production monitoring
- Authentication Script - A bash script that implements the complete Enphase OAuth + PKCE authentication flow (for debugging)
- Lux Sensor Integration - Child devices that convert power readings to illuminance values for creative smart home automations
- Solar Production: Current power generation from your solar panels
- Home Consumption: Real-time power usage of your home
- Export Power: Amount of power being exported back to the grid
- Net Consumption: Import/export balance (negative = exporting, positive = importing)
- Complete OAuth 2.0 + PKCE authentication flow
- Automatic session management with 24-48 hour validity
- Intelligent re-authentication when sessions expire
- Manual session override capability
- Rate limiting to prevent account lockout
- Native Hubitat Elevation integration
- Child devices for each power metric
- Lux sensor compatibility for creative automations
- Configurable scaling factors
- Real-time updates with configurable polling intervals
- Authentication: The system uses Enphase's OAuth flow to obtain a session cookie
- Data Retrieval: Polls the local Envoy device at
https://envoy.lan/production.json - Data Processing: Parses JSON response to extract key metrics:
production[measurementType="production"].wNowβ Solar productionconsumption[measurementType="total-consumption"].wNowβ Home consumptionconsumption[measurementType="net-consumption"].wNowβ Net consumption/export
The authentication implements the complete Enphase OAuth flow:
- Generate PKCE (Proof Key for Code Exchange) parameters
- Fetch login page and extract CSRF tokens
- Submit credentials to Enphase portal
- Extract authorization code from callback
- Exchange code for JWT access token
- Exchange JWT for local session cookie
- Hubitat Elevation hub
- Enphase Envoy system on local network
- Enphase account credentials
- Envoy accessible at
envoy.lanor custom IP
-
Import Driver Code:
- Copy the contents of
enphase-envoy-driver-v4.groovy - In Hubitat web interface, go to Drivers Code
- Click New Driver, paste code, and Save
- Copy the contents of
-
Create Device:
- Go to Devices β Add Device β Virtual
- Choose "Enphase Envoy Solar Monitor v4" as device type
- Configure device name and save
-
Configure Settings:
Envoy IP Address: envoy.lan (or your Envoy's IP) Enphase Username: your-enphase-account@email.com Enphase Password: your-enphase-password Poll Interval: 5 minutes (recommended) Scale Factor: 1000 (for lux conversion) Session Duration: 24 hours -
Create Child Devices:
- Click Create Child Devices command in device page
- This creates separate sensors for production, consumption, and export
For standalone authentication or debugging:
# Set environment variables (required)
export ENPHASE_USERNAME="your-email@example.com"
export ENPHASE_PASSWORD="your-password"
export ENVOY_HOST="envoy.lan" # optional, defaults to envoy.lan
# Run authentication
./enphase-auth.shThe script will:
- Complete the full OAuth flow
- Output the session ID
- Save session ID to
session_id.txt - Test access to production data
# Using saved session ID
curl -k -b "sessionId=$(cat session_id.txt)" "https://envoy.lan/production.json"
# Using specific session ID
curl -k -b "sessionId=YOUR_SESSION_ID" "https://envoy.lan/production.json"| Setting | Description | Default | Range |
|---|---|---|---|
| Envoy IP Address | IP or hostname of Envoy | envoy.lan |
- |
| Enphase Username | Account email | - | Required |
| Enphase Password | Account password | - | Required |
| Poll Interval | Update frequency | 5 minutes | 1-60 min |
| Scale Factor | Lux conversion divisor | 1000 | Any number |
| Session Duration | Assumed session validity | 24 hours | 1-72 hours |
| Manual Session ID | Override auto-auth | - | Optional |
| Variable | Description | Required |
|---|---|---|
ENPHASE_USERNAME |
Enphase account email | Yes |
ENPHASE_PASSWORD |
Enphase account password | Yes |
ENVOY_HOST |
Envoy hostname/IP | No (defaults to envoy.lan) |
The Envoy returns data in this format (from sample_output.json):
{
"production": [
{
"type": "eim",
"measurementType": "production",
"wNow": 10798.302,
"whLifetime": 42876.984
}
],
"consumption": [
{
"measurementType": "total-consumption",
"wNow": 680.76
},
{
"measurementType": "net-consumption",
"wNow": -10117.541
}
]
}Since the system creates lux sensors, you can create creative automations:
- Bright = High Production: Use solar production lux to trigger "sunny day" scenes
- Export Notifications: Alert when exporting significant power
- Load Management: Start energy-intensive devices when production is high
// Turn on pool pump when solar production > 5000W (5 lux with scale factor 1000)
if (solarProductionLux > 5) {
poolPump.on()
}
// Send notification when exporting > 8000W
if (exportPowerLux > 8) {
sendNotification("High solar export: ${exportPower}W")
}Authentication Failures
- Verify credentials are correct
- Check if Envoy is accessible at specified IP
- Try manual session ID if auto-auth fails
- Check for account lockout (wait 1 hour)
No Data Updates
- Verify poll interval is set and > 0
- Check device logs for HTTP errors
- Ensure Envoy is responding to production.json requests
- Try refreshing device manually
Session Expiration
- Sessions typically last 24-48 hours
- Driver automatically re-authenticates
- Use "Clear Session" command to force re-auth
- Check session expiry time in device attributes
Enable detailed logging in device settings:
- Enable debug logging: Shows data parsing and HTTP details
- Enable authentication logging: Shows OAuth flow details
Available device commands for troubleshooting:
- Refresh: Force immediate data update
- Authenticate: Force new authentication
- Clear Session: Invalidate current session
- Create Child Devices: Recreate child sensors
- Delete Child Devices: Remove child sensors
- Credentials: Never commit credentials to version control
- Local Network: All data requests go to local Envoy device
- Session Management: Sessions are automatically managed and renewed
- Rate Limiting: Built-in protection against account lockout
βββ enphase-auth.sh # Standalone authentication script
βββ enphase-envoy-driver-v4.groovy # Main Hubitat driver
βββ enphase-envoy-lux-sensor.groovy # Child device driver
βββ README.md # This file
# Test authentication flow
./enphase-auth.sh
# Verify session works
curl -k -b "sessionId=$(cat session_id.txt)" "https://envoy.lan/production.json" | jq- Fork the repository
- Create a feature branch
- Test changes thoroughly with your Envoy system
- Submit a pull request with clear description
Licensed under the Apache License, Version 2.0. See the driver file header for full license terms.
- Enphase Energy for the Envoy system
- Hubitat Elevation community
- OAuth 2.0 / PKCE specification authors
Note: This project is not officially affiliated with Enphase Energy. Use at your own risk and ensure compliance with Enphase terms of service.