homebridge-crestron-json
v0.4.0
Published
A Homebridge plugin that exposes Crestron devices as HomeKit accessories, allowing you to control your Crestron system through Apple's Home app and Siri.
Maintainers
Readme
Crestron Bridge
A Homebridge plugin that exposes Crestron devices as HomeKit accessories, allowing you to control your Crestron system through Apple's Home app and Siri.
Features
- Lightbulb Control: Control Crestron lighting devices with on/off and brightness functionality
- Switch Control: Control Crestron switch devices with on/off functionality
- Television Control: Control Crestron TVs with power, input selection, volume, mute, and remote key functionality
- Thermostat Control: Control Crestron thermostats with temperature settings, heating/cooling modes, and temperature scale selection
- Real-time Communication: Bidirectional communication with Crestron processors via TCP/IP
- Automatic Reconnection: Handles network disconnections and automatically reconnects
- JSON Protocol: Uses JSON for structured communication with Crestron systems
Installation
If you are running Homebridge on a Raspberry Pi or similar device, you can install this plugin using:
sudo npm install -g homebridge-crestron-jsonConfiguration
Add the following to your Homebridge config.json:
{
"platforms": [
{
"platform": "Crestron Bridge",
"name": "Crestron Bridge",
"host": "192.168.1.100",
"port": 50005,
"lightbulbs": [
{
"id": 1,
"name": "Living Room Light"
},
{
"id": 2,
"name": "Kitchen Light"
}
],
"switches": [
{
"id": 1,
"name": "Living Room Fan"
},
{
"id": 2,
"name": "Kitchen Outlet"
}
],
"televisions": [
{
"id": 1,
"name": "Living Room TV"
}
],
"thermostats": [
{
"id": 1,
"name": "Living Room Thermostat"
},
{
"id": 2,
"name": "Bedroom Thermostat"
}
]
}
]
}Configuration Options
| Option | Type | Required | Default | Description |
| ------------- | ------ | -------- | ------- | ------------------------------------------------- |
| platform | string | Yes | - | Must be "Crestron Bridge" |
| name | string | Yes | - | Display name for the platform (Crestron Bridge) |
| host | string | Yes | - | IP address or hostname of your Crestron processor |
| port | number | No | 50005 | TCP port for Crestron communication |
| lightbulbs | array | No | [] | Array of lightbulb device configurations |
| switches | array | No | [] | Array of switch device configurations |
| televisions | array | No | [] | Array of television device configurations |
| thermostats | array | No | [] | Array of thermostat device configurations |
Lightbulb Device Configuration
Each lightbulb device requires:
| Option | Type | Required | Description |
| ------ | ------ | -------- | --------------------------------------------------------- |
| id | number | Yes | Unique identifier for this device in your Crestron system |
| name | string | Yes | Display name for this device in HomeKit |
Switch Device Configuration
Each switch device requires:
| Option | Type | Required | Description |
| ------ | ------ | -------- | --------------------------------------------------------- |
| id | number | Yes | Unique identifier for this device in your Crestron system |
| name | string | Yes | Display name for this device in HomeKit |
Television Device Configuration
Each television device requires:
| Option | Type | Required | Description |
| ------ | ------ | -------- | --------------------------------------------------------- |
| id | number | Yes | Unique identifier for this device in your Crestron system |
| name | string | Yes | Display name for this device in HomeKit |
Thermostat Device Configuration
Each thermostat device requires:
| Option | Type | Required | Description |
| ------ | ------ | -------- | --------------------------------------------------------- |
| id | number | Yes | Unique identifier for this device in your Crestron system |
| name | string | Yes | Display name for this device in HomeKit |
Supported Features
- Temperature Control: Set target temperature with validation (16-32°C or 60-90°F)
- Temperature Scale: Switch between Celsius and Fahrenheit
- Heating/Cooling Modes: Auto, Heat, Cool, and Off modes
- Current Temperature: Read current temperature from Crestron system
Example JSON Protocol for Thermostat
Target Temperature:
{
"deviceType": "Thermostat",
"id": 1,
"command": "targetTemperature",
"value": 220
}Current Temperature:
{
"deviceType": "Thermostat",
"id": 1,
"command": "currentTemperature",
"value": 215
}Note: Crestron uses 3-digit integers for temperatures (e.g., 220 = 22.0°C, 215 = 21.5°C)
Target Heating Cooling State:
{
"deviceType": "Thermostat",
"id": 1,
"command": "targetHeatingCoolingState",
"value": 3
}Current Heating Cooling State:
{
"deviceType": "Thermostat",
"id": 1,
"command": "currentHeatingCoolingState",
"value": 1
}Temperature Display Units:
{
"deviceType": "Thermostat",
"id": 1,
"command": "temperatureDisplayUnits",
"value": 0
}Television Supported Features
- Power: On/Off
- Input Selection: Choose HDMI or other sources
- Volume: (May not be visible in Apple Home app, but available in third-party HomeKit apps)
- Mute: Mute/unmute TV
- Remote Key: Simulate remote control key presses
Example JSON Protocol for Television
Power:
{
"deviceType": "Television",
"id": 1,
"command": "power",
"value": true
}Input Selection:
{
"deviceType": "Television",
"id": 1,
"command": "input",
"value": 2
}Volume:
{
"deviceType": "Television",
"id": 1,
"command": "volume",
"value": 30
}Mute:
{
"deviceType": "Television",
"id": 1,
"command": "mute",
"value": true
}Remote Key:
{
"deviceType": "Television",
"id": 1,
"command": "remoteKey",
"value": 3
}Crestron Integration
JSON Protocol
This plugin communicates with Crestron using JSON messages. The protocol expects the following message format:
Commands sent to Crestron:
Lightbulb commands:
{
"deviceType": "Lightbulb",
"id": 1,
"command": "power",
"value": true
}{
"deviceType": "Lightbulb",
"id": 1,
"command": "brightness",
"value": 75
}Switch commands:
{
"deviceType": "Switch",
"id": 1,
"command": "power",
"value": true
}Television commands:
{
"deviceType": "Television",
"id": 1,
"command": "power",
"value": true
}{
"deviceType": "Television",
"id": 1,
"command": "input",
"value": 2
}{
"deviceType": "Television",
"id": 1,
"command": "volume",
"value": 30
}{
"deviceType": "Television",
"id": 1,
"command": "mute",
"value": true
}{
"deviceType": "Television",
"id": 1,
"command": "remoteKey",
"value": 3
}Thermostat commands:
{
"deviceType": "Thermostat",
"id": 1,
"command": "targetTemperature",
"value": 220
}Note: Crestron uses 3-digit integers for temperatures (e.g., 220 = 22.0°C)
{
"deviceType": "Thermostat",
"id": 1,
"command": "targetHeatingCoolingState",
"value": 3
}{
"deviceType": "Thermostat",
"id": 1,
"command": "temperatureDisplayUnits",
"value": 0
}Responses expected from Crestron:
Lightbulb responses:
{
"deviceType": "Lightbulb",
"id": 1,
"command": "power",
"value": true
}{
"deviceType": "Lightbulb",
"id": 1,
"command": "brightness",
"value": 75
}Switch responses:
{
"deviceType": "Switch",
"id": 1,
"command": "power",
"value": true
}Television responses:
{
"deviceType": "Television",
"id": 1,
"command": "power",
"value": true
}{
"deviceType": "Television",
"id": 1,
"command": "input",
"value": 2
}{
"deviceType": "Television",
"id": 1,
"command": "volume",
"value": 30
}{
"deviceType": "Television",
"id": 1,
"command": "mute",
"value": true
}{
"deviceType": "Television",
"id": 1,
"command": "remoteKey",
"value": 3
}Thermostat responses:
{
"deviceType": "Thermostat",
"id": 1,
"command": "currentTemperature",
"value": 215
}{
"deviceType": "Thermostat",
"id": 1,
"command": "targetTemperature",
"value": 220
}Note: Crestron uses 3-digit integers for temperatures (e.g., 215 = 21.5°C, 220 = 22.0°C)
{
"deviceType": "Thermostat",
"id": 1,
"command": "currentHeatingCoolingState",
"value": 1
}{
"deviceType": "Thermostat",
"id": 1,
"command": "targetHeatingCoolingState",
"value": 3
}{
"deviceType": "Thermostat",
"id": 1,
"command": "temperatureDisplayUnits",
"value": 0
}Crestron Programming
You'll need to set up your Crestron processor to:
- Listen for TCP connections on the configured port (default: 50005)
- Parse incoming JSON messages and route commands to appropriate devices
- Send JSON responses when device states change
- Handle device state updates and send notifications back to Homebridge
Important Note for Thermostat Temperatures:
- Crestron uses 3-digit integers for temperature values (e.g., 220 = 22.0°C, 215 = 21.5°C)
- The Homebridge plugin automatically converts between HomeKit's decimal format and Crestron's integer format
- When sending temperature data to Crestron, multiply by 10 (22.5°C → 225)
- When receiving temperature data from Crestron, divide by 10 (225 → 22.5°C)
Troubleshooting
Connection Issues
- Check IP Address: Ensure the
hostfield contains the correct IP address of your Crestron processor - Verify Port: Confirm the port number matches your Crestron configuration
- Network Connectivity: Test network connectivity between Homebridge and Crestron
- Firewall: Ensure the port is not blocked by firewalls
Device Not Responding
- Check Device IDs: Verify that device IDs in the configuration match those in your Crestron system
- JSON Format: Ensure Crestron is sending properly formatted JSON responses
- Logs: Check Homebridge logs for error messages or malformed JSON
Debug Mode
Run Homebridge in debug mode to see detailed logs:
homebridge -DLook for messages related to:
- Connection status
- JSON parsing
- Device state changes
- Error messages
Development
Building from Source
git clone https://github.com/your-username/homebridge-crestron-json.git
cd homebridge-crestron-json
npm install
npm run build
npm linkTesting
npm run watchThis will start Homebridge in watch mode, automatically rebuilding and restarting when you make changes.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any issues or have questions:
- Check the troubleshooting section
- Search existing issues
- Create a new issue with detailed information about your problem
Changelog
1.1.0
- Added Thermostat accessory support
- Temperature control with validation (16-32°C or 60-90°F)
- Temperature scale selection (Celsius/Fahrenheit)
- Heating/cooling modes (Auto, Heat, Cool, Off)
- Current and target temperature monitoring
1.0.0
- Initial release
- Lightbulb accessory support
- Switch accessory support
- Television accessory support
- JSON-based communication protocol
- Automatic reconnection handling
