npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

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.

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-json

Configuration

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:

  1. Listen for TCP connections on the configured port (default: 50005)
  2. Parse incoming JSON messages and route commands to appropriate devices
  3. Send JSON responses when device states change
  4. 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 host field 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 -D

Look 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 link

Testing

npm run watch

This will start Homebridge in watch mode, automatically rebuilding and restarting when you make changes.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. 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:

  1. Check the troubleshooting section
  2. Search existing issues
  3. 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