This plugin enables you to control your MagicBlue LED light bulbs through HomeKit via Homebridge using a dynamic platform plugin.
npm install -g homebridge-magic-blue-bulb
You may need to use sudo
with that command.
Add this platform to your homebridge config.json
:
{
"platforms": [
{
"name": "Magic Blue Bulbs",
"platform": "MagicBlueBulbPlatform",
"bulbs": [
{
"name": "Living Room Light",
"mac": "aa:bb:cc:dd:ee:ff",
"handle": 12,
"manufacturer": "Magic Blue",
"model": "RGB Bulb",
"serial": "MB001"
},
{
"name": "Bedroom Light",
"mac": "ff:ee:dd:cc:bb:aa",
"handle": 12,
"manufacturer": "Magic Blue",
"model": "RGB Bulb",
"serial": "MB002"
}
]
}
]
}
This plugin uses Zod for runtime configuration validation, providing enhanced error reporting and type safety:
- MAC Address Validation: Ensures MAC addresses follow the correct format (e.g.,
AA:BB:CC:DD:EE:FF
oraa-bb-cc-dd-ee-ff
) - Required Fields: Validates that essential fields like
name
andmac
are present and non-empty - Type Safety: Ensures numeric fields like
handle
are proper integers - Clear Error Messages: Provides detailed error messages when configuration is invalid
If you provide an invalid configuration, you'll see helpful error messages in the Homebridge logs:
[Magic Blue Bulbs] Configuration validation failed: mac: Invalid MAC address format, name: Bulb name is required
Key | Description |
---|---|
name |
Required. The name of this platform instance |
platform |
Required. Must be "MagicBlueBulbPlatform" |
bulbs |
Required. Array of bulb configurations (see below) |
Key | Description |
---|---|
name |
Required. The name of this bulb in your HomeKit app |
mac |
Required. The MAC address of your Magic Blue bulb |
handle |
Optional. BLE handle for commands. Use 46 for newer bulbs, defaults to 12 (0x000c) for older versions |
manufacturer |
Optional. Manufacturer name, defaults to "Light" |
model |
Optional. Model name, defaults to "Magic Blue" |
serial |
Optional. Serial number, defaults to "5D4989E80E44" |
If you're upgrading from v1.x, you'll need to update your configuration from an accessory-based setup to a platform-based setup:
{
"accessories": [
{
"accessory": "magic-blue-bulb",
"name": "Magic Blue Bulb",
"mac": "aa:bb:cc:dd:ee:ff"
}
]
}
{
"platforms": [
{
"name": "Magic Blue Bulbs",
"platform": "MagicBlueBulbPlatform",
"bulbs": [
{
"name": "Magic Blue Bulb",
"mac": "aa:bb:cc:dd:ee:ff"
}
]
}
]
}
The new platform plugin architecture provides several advantages:
- Multiple Bulbs: Easily manage multiple Magic Blue bulbs from a single platform configuration
- Better Performance: Improved caching and accessory management
- Future-Proof: Uses Homebridge's recommended modern architecture
- Easier Management: Centralized configuration for all your Magic Blue devices
The light bulb uses Bluetooth Low Energy. To discover your bulb's MAC address, install bluez and run:
sudo hcitool lescan
Look for a device named "LEDBLE-" followed by some characters - that's your Magic Blue bulb.
Example output:
LE Scan ...
FF:FF:C8:5D:68:9E Eve
FF:FF:C8:5D:68:9E Eve Thermo
33:03:44:44:AA:5C (unknown)
33:03:44:44:AA:5C Eve Door
aa:bb:cc:dd:ee:ff (unknown)
22:20:7B:99:D3:AF (unknown)
aa:bb:cc:dd:ee:ff LEDBLE-A582661F <--- this is your light bulb
22:20:7B:99:D3:AF (unknown)
This project is written in TypeScript. To develop and contribute:
npm install
npm run build
npm run watch
The TypeScript source files are in src/
and the compiled JavaScript output is in dist/
.
homebridge-magic-blue-bulb/
├── src/
│ ├── index.ts # Plugin registration and entry point
│ ├── platform.ts # Main platform class
│ ├── accessory.ts # Individual bulb accessory implementation
│ ├── constants.ts # BLE commands and default values
│ ├── rgbConversion.ts # HSL/RGB color conversion utilities
│ └── types.ts # TypeScript type definitions and validation
├── dist/ # Compiled JavaScript output
├── tsconfig.json # TypeScript configuration
└── package.json # Dependencies and scripts
- Node.js >= 22.0.0
- Homebridge >= 1.6.0 (compatible with Homebridge v2.0)
- Bluetooth LE support on your system
This plugin is fully compatible with Homebridge v2.0! It uses:
- ✅ Modern platform plugin architecture
- ✅ Current HAP-NodeJS APIs (no deprecated patterns)
- ✅ Proper TypeScript implementation with strict typing
- ✅ Zod validation for enhanced configuration safety
Users will see a green checkmark in the Homebridge UI once v2.0 is installed.
This software comes with no warranty. It works for me and it might for you. If you encounter issues, please open an issue on GitHub.
- Bluetooth protocol discovered by the author of this post and used in this repository
- Color conversion methods by Garry Tan - see his post here
GPL-3.0