forked from wled/WLED
-
-
Notifications
You must be signed in to change notification settings - Fork 128
Add WiFi-only Matter (CHIP) usermod for WLED-MM #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
3
commits into
mdev
Choose a base branch
from
copilot/add-wifi-only-matter-support
base: mdev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+471
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # Matter (Project CHIP) WiFi-only Usermod | ||
|
|
||
| This usermod adds **Matter smart-home protocol** support to WLED-MM, allowing the device to appear natively in **Apple Home, Google Home, and Amazon Alexa** Matter ecosystems — without requiring Bluetooth/BLE. | ||
|
|
||
| ## Features | ||
|
|
||
| | Feature | Details | | ||
| |---|---| | ||
| | **Device type** | Extended Color Light (`0x010D`) | | ||
| | **Commissioning** | WiFi only — Soft-AP or on-network (mDNS) | | ||
| | **BLE requirement** | None (`CONFIG_BT_ENABLED=n`) | | ||
| | **Clusters** | On/Off · Level Control (brightness) · Color Control (HSV + Color Temperature) | | ||
| | **State sync** | Bidirectional — Matter ↔ WLED UI / API / presets | | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **WLED connects to WiFi** as usual (via the WLED web UI or AP setup). | ||
| 2. The **Matter stack** starts and advertises the device via **mDNS** on the local network. | ||
| 3. A Matter commissioner (Apple Home, Google Home, etc.) discovers the device and commissions it using the **setup PIN** and **discriminator**. | ||
| 4. Once commissioned, the controller can turn the light on/off, adjust brightness, and change colour — all changes are bridged to WLED's internal colour state. | ||
| 5. Changes made through the WLED web UI, HTTP API, or presets are **automatically synced back** to the Matter fabric. | ||
|
|
||
| If the device has **no WiFi credentials** at first boot, the Matter stack creates a **Soft-AP** (`CHIP-XXXX`) so the commissioner can provision both the WiFi network and the Matter fabric in one step. | ||
|
|
||
| ## Build Requirements | ||
|
|
||
| | Requirement | Minimum version | | ||
| |---|---| | ||
| | ESP-IDF | v5.1+ | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure? |
||
| | `esp_matter` component | latest from [Espressif Component Registry](https://components.espressif.com/components/espressif/esp_matter) | | ||
| | Target SoC | ESP32-S3, ESP32-C3, or ESP32-H2 (classic ESP32 has limited support) | | ||
| | PlatformIO platform | `espressif32` ≥ 6.4.0 (ESP-IDF v5.1 based) | | ||
|
|
||
| > **Note:** The Matter SDK is large. Builds with this usermod require an ESP32-S3 (or similar) with at least 8 MB flash. PSRAM is recommended. | ||
|
|
||
| ## Build Environment | ||
|
|
||
| A ready-made PlatformIO build environment is provided in `platformio.ini`: | ||
|
|
||
| ```ini | ||
| [env:esp32s3_matter_wifi] | ||
| ``` | ||
|
|
||
| To build: | ||
|
|
||
| ```bash | ||
| # Build web UI first (required before any firmware build) | ||
| npm run build | ||
|
|
||
| # Build the Matter-enabled firmware | ||
| pio run -e esp32s3_matter_wifi | ||
| ``` | ||
|
|
||
| ## Enabling in a Custom Build | ||
|
|
||
| Add these flags to your PlatformIO environment's `build_flags`: | ||
|
|
||
| ```ini | ||
| build_flags = | ||
| -D USERMOD_MATTER | ||
| -D CONFIG_BT_ENABLED=0 | ||
| ``` | ||
|
|
||
| And ensure `esp_matter` is available as a library/component dependency. | ||
|
|
||
| ## Configuration | ||
|
|
||
| After flashing, the following settings are available in **WLED Settings → Usermods → Matter**: | ||
|
|
||
| | Setting | Default | Description | | ||
| |---|---|---| | ||
| | `passcode` | `20202021` | Matter setup PIN code (8-digit numeric). Change for production use. | | ||
| | `discriminator` | `3840` | 12-bit discriminator for device discovery. | | ||
|
|
||
| ## Commissioning | ||
|
|
||
| ### Using Apple Home | ||
| 1. Open the **Home** app → **+** → **Add Accessory**. | ||
| 2. Choose **More options…** → the WLED device should appear. | ||
| 3. Enter the setup PIN when prompted (default: `20202021`). | ||
|
|
||
| ### Using Google Home | ||
| 1. Open the **Google Home** app → **+** → **Set up device** → **New device**. | ||
| 2. Select **Matter** as the device type. | ||
| 3. Enter the manual pairing code. | ||
|
|
||
| ### Using a Matter Test Tool | ||
| ```bash | ||
| chip-tool pairing onnetwork <node-id> 20202021 | ||
| ``` | ||
|
|
||
| ## Technical Details | ||
|
|
||
| - **Thread safety**: Matter callbacks run on the Matter task. Pending state is transferred to WLED via volatile flags and applied in the Arduino `loop()` context. | ||
| - **Colour mapping**: Matter hue (0–254) is scaled to WLED's `colorHStoRGB()` range (0–65535). Matter saturation (0–254) maps to WLED's 0–255 range. Colour temperature is passed as mireds to `colorCTtoRGB()`. | ||
| - **Sync interval**: WLED → Matter state is pushed every 250 ms to avoid flooding the Matter fabric with attribute reports. | ||
|
|
||
| ## Memory Impact | ||
|
|
||
| With `CONFIG_BT_ENABLED=n`: | ||
| - **RAM**: ~40–60 KB additional (vs ~100–160 KB with BLE) | ||
| - **Flash**: ~400–600 KB additional for the Matter/CHIP stack | ||
|
|
||
| ## Files | ||
|
|
||
| | File | Purpose | | ||
| |---|---| | ||
| | `usermods/usermod_v2_matter/usermod_v2_matter.h` | Usermod implementation | | ||
| | `usermods/usermod_v2_matter/readme.md` | This documentation | | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the esp-idf requirement correct? WLED-MM does not have esp-idf V5 support.