homebridge-controld v0.1.0
A Homebridge plugin to control Control D DNS profile filtering through HomeKit.
What is Control D?
Control D is a next-generation DNS service that gives you advanced filtering capabilities, analytics, and custom routing. It offers features like ad-blocking, malware protection, and content filtering across your devices.
Features
- ✅ Exposes Control D profiles as HomeKit switches
- ✅ Enable or disable DNS filtering for profiles using the Home app or Siri
- ✅ Automatically detects profile status changes
- ✅ Easily integrate with HomeKit scenes and automations
- ✅ Secure API connection with Control D
Prerequisites
- Homebridge v1.8.0 or newer
- A Control D account
- Control D API token
Installation
Option 1: Install through Homebridge UI
- Open the Homebridge UI
- Go to the "Plugins" tab
- Search for "homebridge-controld"
- Click "Install"
Option 2: Install through terminal
npm install -g homebridge-controld
Configuration
You can configure the plugin through the Homebridge UI or by editing your config.json
file directly.
Through Homebridge UI
- Navigate to the "Plugins" tab
- Find "Homebridge Control D" and click "Settings"
- Enter your Control D API token and other settings
- Save and restart Homebridge
Manual Configuration
Add the following to your Homebridge config.json
file:
{
"platforms": [
{
"platform": "ControlDPlatform",
"name": "Control D",
"apiToken": "YOUR_CONTROL_D_API_TOKEN",
"refreshInterval": 60,
"debug": false
}
]
}
Configuration Options
Option | Required | Default | Description |
---|---|---|---|
platform | Yes | Must be "ControlDPlatform" | |
name | Yes | "Control D" | Name for your Control D platform |
apiToken | Yes | Your Control D API token | |
refreshInterval | No | 60 | Interval in seconds to refresh profile status |
debug | No | false | Enable additional debug logging |
API Token Configuration
Getting Your Control D API Token
To use this plugin, you need a valid API token from Control D with the appropriate permissions:
- Log in to your Control D dashboard at https://controld.com/dashboard
- Go to "Settings" in the left sidebar
- Click on "API" in the settings menu
- Click "Create API Token"
- Give your token a name (e.g., "Homebridge")
Required Permissions: Make sure to select these permissions:
profiles:read
- Required to list available DNS profilesprofiles:write
- Required to modify DNS profiles
Important: You must select BOTH permissions above
Click "Generate Token"
- Copy the token immediately (you won't be able to see it again)
API Endpoints Used
This plugin interacts with the following Control D API endpoints:
GET /profiles
- Retrieves list of available DNS profilesPUT /profiles/{profileId}
- Updates a profile's filtering settings
Common Authentication Errors
If you see error messages like these in your Homebridge logs:
[Control D] Failed to get profiles: AxiosError: Request failed with status code 403
This indicates an authentication problem. The most common issue is missing permissions:
Error Code 40301 - Missing Endpoint Permission
If you see a message like:
This token does not have access to this endpoint
This means your token is valid but doesn't have the required permissions. You need to:
- Go to Control D dashboard → Settings → API
- Revoke your existing token (it cannot be modified)
- Create a new token with the required permissions listed above
- Update your Homebridge config with the new token
- Restart Homebridge
Other Common Issues
- Invalid token: Make sure you've copied the full token correctly
- Account issues: Verify your Control D account is active
- Token revoked: If you've revoked the token, you'll need to create a new one
Troubleshooting API Access
Test your token using curl:
curl -X GET "https://api.controld.com/profiles" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_TOKEN_HERE"
Check the response:
- If you get data back, your token is working
- If you get a 403 error with code 40301, your token is missing permissions
- If you get another error, check the error message for details
Create a new token with the correct permissions if needed
Usage
After setting up the plugin and restarting Homebridge, your Control D profiles will appear as switches in the Home app.
Basic Usage
- Turn ON a profile switch: Enables DNS filtering for that profile
- Turn OFF a profile switch: Disables DNS filtering for that profile
- Refresh status: The plugin automatically refreshes profile status every minute (configurable)
HomeKit Automation Examples
- Schedule filter changes: Create automations to enable/disable filtering based on time of day
- Activate filters when leaving home: Use location-based triggers to enable stricter filtering
- Scene integration: Include filtering changes in your HomeKit scenes
Troubleshooting
Common Issues
Plugin not showing in HomeKit
- Ensure Homebridge is running properly
- Check that your API token is correct
- Verify your Control D account has at least one profile
Can't toggle profile filtering
- Verify your API token has the necessary permissions
- Check if your Control D account has at least one profile
Updates not reflecting in the Home app
- Try increasing the refresh interval in the configuration
- Restart Homebridge
Viewing Logs
For detailed troubleshooting, enable debug mode by setting "debug": true
in your configuration. You can view the logs through the Homebridge UI or in the Homebridge log file.
Development
This section is for developers who want to contribute to or modify the plugin.
Development Setup
Clone the repository:
git clone https://github.com/brandonarrindell/homebridge-controld.git cd homebridge-controld
Install dependencies:
npm install
Create a
.env
file in the project root with your Control D API token:CONTROLD_API_TOKEN=api.your_token_here
Note: The
.env
file is only used for development and testing. It should never be committed to the repository.Build the plugin:
npm run build
Running Tests
Tests are provided for development purposes to ensure the API client works correctly. These tests require a valid Control D API token with proper permissions.
npm test
Important: The integration tests make real API calls that may temporarily change your profile settings. While the tests attempt to restore settings to their original state, they should only be run in a development environment, not on production profiles.
See the test/README.md
file for more details about the test structure.
Development Workflow
- Make your changes
- Run tests:
npm test
- Build the plugin:
npm run build
- Link for local testing:
npm link
- Test in Homebridge: Configure Homebridge to use your development version
Support and Contribution
- Report issues on GitHub
- Pull requests are welcome!
License
Apache-2.0