A bridge application that connects SmartThings HVAC devices to HomeKit/HomeKit, allowing you to control your SmartThings devices through Apple's Home app and other HomeKit-compatible platforms.
- Bridge SmartThings devices to HomeKit via HomeKit protocol
- OAuth integration with SmartThings platform
- Web-based device management interface
- Real-time device state synchronization
- HomeKit Accessory Protocol (HAP) support
- Node.js 18.0.0 or higher
- SmartThings Developer Account
- ngrok (for OAuth callback during development)
- SmartThings CLI
- Clone the repository and install dependencies:
npm install- Build the project:
npm run buildYou'll need a public URL for the SmartThings OAuth callback. Use ngrok to create a tunnel to your local server. You can shut it down once you've done the oauth handshake:
- Install ngrok if you haven't already:
# Using npm
npm install -g ngrok
# Using Homebrew (macOS)
brew install ngrok
# Or download from https://ngrok.com/download- Start your application first:
npm run dev- In a separate terminal, create a tunnel to localhost:3000:
ngrok http 3000- Note the public HTTPS URL provided by ngrok (e.g.,
https://abc123.ngrok.io)
- Install the SmartThings CLI:
npm install -g @smartthings/cli- Login to your SmartThings account:
smartthings login- Create a new SmartThings application:
smartthings apps:createFollow the interactive prompts:
- Application Name: Choose a name for your app (e.g., "HomeKit Bridge")
- Display Name: User-friendly name
- Description: Brief description of your app
- App Type: Select "WebHook SmartApp"
- Classifications: Select appropriate classifications
- OAuth: Choose "Yes" to enable OAuth
- Configure OAuth settings:
smartthings apps:oauth [APP_ID]When prompted, set:
- Client Name: Your app name
- Scope: Select the scopes you need (typically
r:devices:*andx:devices:*) - Redirect URIs: Use your ngrok URL + callback path:
https://your-ngrok-url.ngrok.io/auth/smartthings/callback
- Get your OAuth credentials:
smartthings apps:oauth [APP_ID]This will display your CLIENT_ID and CLIENT_SECRET.
- Copy the example environment file:
cp .env.example .env- Edit the
.envfile with your configuration:
# SmartThings OAuth Configuration
SMARTTHINGS_CLIENT_ID=your_client_id_from_cli
SMARTTHINGS_CLIENT_SECRET=your_client_secret_from_cli
SMARTTHINGS_REDIRECT_URI=https://your-ngrok-url.ngrok.io/auth/smartthings/callback
# Server Configuration
PORT=3000
WEB_PORT=3000
HAP_PORT=51826
HAP_PINCODE=942-37-286
SESSION_SECRET=your-random-session-secret-here
# Storage Paths
AUTH_TOKEN_PATH=./data/smartthings_token.json
DEVICE_STATE_PATH=./data/device_state.json
# Device Configuration (comma-separated device IDs for lighting monitor)
LIGHTING_MONITOR_DEVICES=device1,device2,device3,device4
# Update Intervals (in seconds)
DEVICE_POLL_INTERVAL=300
LIGHTING_CHECK_INTERVAL=60Important Notes:
- Replace
your_client_id_from_cliandyour_client_secret_from_cliwith the values from the SmartThings CLI - Replace
your-ngrok-url.ngrok.iowith your actual ngrok URL - Generate a secure random string for
SESSION_SECRET - Create the
./datadirectory if it doesn't exist
For production deployment, update your SmartThings app's redirect URI:
smartthings apps:oauth:update [APP_ID]Replace the ngrok URL with your production domain.
The easiest way to run the SmartThings HomeKit Bridge is using Docker:
- Create a
.envfile with your SmartThings credentials:
SMARTTHINGS_CLIENT_ID=your_client_id_from_cli
SMARTTHINGS_CLIENT_SECRET=your_client_secret_from_cli
SMARTTHINGS_REDIRECT_URI=http://your-domain:3000/auth/callback- Start the application:
docker-compose up -d- Access the web interface at
http://localhost:3000
# Build the Docker image
docker build -t smartthings-bridge .
# Run the container
docker run -d \
--name smartthings-homekit-bridge \
-p 3000:3000 \
-p 5353:5353/udp \
-e SMARTTHINGS_CLIENT_ID=your_client_id \
-e SMARTTHINGS_CLIENT_SECRET=your_client_secret \
-v homekit_data:/app/homekit \
smartthings-bridgeSMARTTHINGS_CLIENT_ID- Your SmartThings OAuth client IDSMARTTHINGS_CLIENT_SECRET- Your SmartThings OAuth client secretSMARTTHINGS_REDIRECT_URI- OAuth redirect URI (defaults tohttp://localhost:3000/auth/callback)NODE_ENV- Set toproductionfor production deployments
/app/homekit- Persists HomeKit pairing data across container restarts/app/config- Optional configuration directory (read-only)
- Port
3000is used for the web interface - Port
5353/udpis used for mDNS HomeKit discovery - If you experience HomeKit discovery issues, uncomment the
network_mode: hostline indocker-compose.yml
# Development mode
npm run dev
# Production mode
npm run build
npm start- Visit
http://localhost:3000 - Click "Connect to SmartThings" to authenticate
- Authorize the application in SmartThings
- Your HVAC devices will be automatically discovered
- Go to the "HomeKit Setup" tab in the web interface
- Use the QR code or manual pairing code to add the bridge to HomeKit
- Your thermostats will appear as individual devices in Apple Home
- SmartThingsAuthentication: Handles OAuth token management and refresh
- SmartThingsAPI: Wrapper for SmartThings API with device filtering
- LightingMonitor: Automated light control for specified devices
- Coordinator: Central state management and device synchronization
- HomeKitServer: HomeKit protocol implementation with thermostat endpoints
- WebServer: REST API and React-based web interface
- Device Discovery: SmartThings API discovers HVAC-capable devices
- State Monitoring: Coordinator polls device states every 5 minutes
- Temperature Sync: Changes trigger synchronization across all devices
- HomeKit Updates: Device states are pushed to HomeKit every second
- Light Control: Lighting monitor checks and controls lights every minute
GET /api/auth/smartthings- Initiate OAuth flowGET /api/auth/smartthings/callback- OAuth callbackGET /api/auth/status- Check authentication status
GET /api/devices- List filtered HVAC devicesGET /api/devices/paired- Get paired devices with statesGET /api/devices/:id- Get specific device statusPOST /api/devices/:id/temperature- Set device temperaturePOST /api/devices/:id/mode- Set device modePOST /api/devices/:id/light/on|off- Control device light
GET /api/matter/pairing- Get QR code and pairing informationGET /api/matter/status- Check HomeKit server status
# Install dependencies
npm install
# Start development server
npm run dev
# Type checking
npm run typecheck
# Build for production
npm run build
# Clean build artifacts
npm run clean- Authentication Failed: Check OAuth credentials and redirect URI
- No Devices Found: Ensure devices have thermostat capabilities
- HomeKit Pairing Failed: Check firewall settings for port 5540
- Token Expired: Tokens are automatically refreshed; check logs for errors
Set environment variable for detailed logging:
DEBUG=* npm run devMonitor application logs for troubleshooting:
- SmartThings API calls and responses
- HomeKit server events and pairing attempts
- Device state changes and synchronization
- OAuth token refresh attempts
MIT License - see LICENSE file for details