Vollständige Next.js 15 Portfolio-Website mit: - Blog-System mit 100+ Artikeln - Supabase-Integration - Responsive Design mit Tailwind CSS - TypeScript-Konfiguration - Testing-Setup mit Vitest und Playwright Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
630 lines
19 KiB
Markdown
630 lines
19 KiB
Markdown
# Matter & Thread: Smart Home Standards
|
|
|
|
**Meta-Description:** Matter und Thread Protokolle für Smart Homes. Interoperabilität, Thread Border Router und Home Assistant Integration.
|
|
|
|
**Keywords:** Matter, Thread, Smart Home, IoT Protocol, Border Router, CSA, Home Assistant, Zigbee
|
|
|
|
---
|
|
|
|
## Einführung
|
|
|
|
**Matter** und **Thread** revolutionieren Smart Homes. Matter bietet Interoperabilität zwischen Apple, Google und Amazon. Thread liefert das energieeffiziente Mesh-Netzwerk. Zusammen die Zukunft vernetzter Häuser.
|
|
|
|
---
|
|
|
|
## Matter & Thread Overview
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────────┐
|
|
│ MATTER & THREAD ARCHITECTURE │
|
|
├─────────────────────────────────────────────────────────────┤
|
|
│ │
|
|
│ Application Layer: │
|
|
│ ┌─────────────────────────────────────────────────────┐ │
|
|
│ │ MATTER │ │
|
|
│ │ (Unified Smart Home Protocol by CSA) │ │
|
|
│ │ - Device Types (Lights, Locks, Sensors, ...) │ │
|
|
│ │ - Secure Commissioning │ │
|
|
│ │ - Local & Cloud Control │ │
|
|
│ └─────────────────────────────────────────────────────┘ │
|
|
│ │ │
|
|
│ Transport Layer: │ │
|
|
│ ┌────────────┬───────────┴───────────┬────────────┐ │
|
|
│ │ WiFi │ Thread │ Ethernet │ │
|
|
│ │ (2.4GHz) │ (Low-Power Mesh) │ │ │
|
|
│ └────────────┴───────────────────────┴────────────┘ │
|
|
│ │
|
|
│ Thread Network: │
|
|
│ ┌─────────────────────────────────────────────────────┐ │
|
|
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
|
|
│ │ │ Border │──────│ Router │──────│ Router │ │ │
|
|
│ │ │ Router │ │ Device │ │ Device │ │ │
|
|
│ │ └────┬─────┘ └────┬─────┘ └────┬─────┘ │ │
|
|
│ │ │ │ │ │ │
|
|
│ │ ┌────┴────┐ ┌────┴────┐ ┌────┴────┐ │ │
|
|
│ │ │ Sleepy │ │ Sleepy │ │ Full │ │ │
|
|
│ │ │Endpoint │ │Endpoint │ │ Device │ │ │
|
|
│ │ └─────────┘ └─────────┘ └─────────┘ │ │
|
|
│ └─────────────────────────────────────────────────────┘ │
|
|
│ │
|
|
│ Device Types: │
|
|
│ - Full Thread Device: Always on, extends mesh │
|
|
│ - Sleepy End Device: Battery, wakes on demand │
|
|
│ - Border Router: Connects Thread to IP network │
|
|
│ │
|
|
└─────────────────────────────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## Matter Device Types
|
|
|
|
```typescript
|
|
// Unterstützte Matter Device Types
|
|
const matterDeviceTypes = {
|
|
// Beleuchtung
|
|
onOffLight: 0x0100,
|
|
dimmableLight: 0x0101,
|
|
colorTemperatureLight: 0x010C,
|
|
extendedColorLight: 0x010D,
|
|
|
|
// Steckdosen & Schalter
|
|
onOffPluginUnit: 0x010A,
|
|
onOffLightSwitch: 0x0103,
|
|
dimmerSwitch: 0x0104,
|
|
|
|
// Sensoren
|
|
contactSensor: 0x0015,
|
|
lightSensor: 0x0106,
|
|
occupancySensor: 0x0107,
|
|
temperatureSensor: 0x0302,
|
|
humiditySensor: 0x0307,
|
|
flowSensor: 0x0306,
|
|
|
|
// Sicherheit
|
|
doorLock: 0x000A,
|
|
windowCovering: 0x0202,
|
|
|
|
// Klima
|
|
thermostat: 0x0301,
|
|
fan: 0x002B,
|
|
airQualitySensor: 0x002C,
|
|
|
|
// Media
|
|
basicVideoPlayer: 0x0028,
|
|
speaker: 0x0022,
|
|
|
|
// Sonstiges
|
|
bridge: 0x000E,
|
|
aggregator: 0x000F
|
|
};
|
|
```
|
|
|
|
---
|
|
|
|
## Thread Network Basics
|
|
|
|
```typescript
|
|
// Thread Network Concepts
|
|
|
|
interface ThreadNetwork {
|
|
networkName: string; // Max 16 Bytes
|
|
extendedPanId: string; // 8 Bytes
|
|
panId: number; // 16-bit
|
|
channel: number; // 11-26 (2.4GHz)
|
|
networkKey: string; // 128-bit AES key
|
|
meshLocalPrefix: string; // IPv6 /64
|
|
}
|
|
|
|
interface ThreadDevice {
|
|
type: 'router' | 'end_device' | 'sleepy_end_device';
|
|
rloc16: number; // 16-bit Router Locator
|
|
extAddress: string; // 64-bit Extended Address
|
|
ipAddresses: string[]; // IPv6 Addresses
|
|
isLeader: boolean;
|
|
isBorderRouter: boolean;
|
|
}
|
|
|
|
// Thread 1.4 Features (ab 2026 required)
|
|
const thread14Features = {
|
|
// Credential Sharing zwischen Border Routern
|
|
credentialSharing: true,
|
|
|
|
// Automatisches Network Joining
|
|
seamlessJoining: true,
|
|
|
|
// Improved Power Management
|
|
enhancedSleepMode: true,
|
|
|
|
// IPv6 Border Routing
|
|
borderRouting: true
|
|
};
|
|
```
|
|
|
|
---
|
|
|
|
## Home Assistant Matter Integration
|
|
|
|
```yaml
|
|
# configuration.yaml
|
|
|
|
# Matter Integration aktivieren
|
|
matter:
|
|
|
|
# Thread Integration
|
|
thread:
|
|
|
|
# Companion App für Commissioning
|
|
mobile_app:
|
|
|
|
# Automatische Erkennung
|
|
default_config:
|
|
```
|
|
|
|
```typescript
|
|
// Matter Device via Home Assistant WebSocket API
|
|
// lib/matter-ha-client.ts
|
|
|
|
import WebSocket from 'ws';
|
|
|
|
interface MatterDevice {
|
|
node_id: number;
|
|
date_commissioned: string;
|
|
last_interview: string;
|
|
interview_version: number;
|
|
available: boolean;
|
|
is_bridge: boolean;
|
|
device_info: {
|
|
vendor_id: number;
|
|
vendor_name: string;
|
|
product_id: number;
|
|
product_name: string;
|
|
node_label: string;
|
|
serial_number: string;
|
|
software_version: number;
|
|
hardware_version: number;
|
|
};
|
|
}
|
|
|
|
class MatterHAClient {
|
|
private ws: WebSocket;
|
|
private messageId = 1;
|
|
|
|
constructor(haUrl: string, token: string) {
|
|
this.ws = new WebSocket(haUrl);
|
|
|
|
this.ws.on('open', () => {
|
|
// Authentifizieren
|
|
this.ws.send(JSON.stringify({
|
|
type: 'auth',
|
|
access_token: token
|
|
}));
|
|
});
|
|
}
|
|
|
|
// Matter Devices abrufen
|
|
async getMatterNodes(): Promise<MatterDevice[]> {
|
|
return this.sendCommand({
|
|
type: 'matter/get_nodes'
|
|
});
|
|
}
|
|
|
|
// Neues Device commissionen
|
|
async commissionDevice(code: string): Promise<void> {
|
|
return this.sendCommand({
|
|
type: 'matter/commission',
|
|
code
|
|
});
|
|
}
|
|
|
|
// Device Interview (Capabilities abfragen)
|
|
async interviewNode(nodeId: number): Promise<void> {
|
|
return this.sendCommand({
|
|
type: 'matter/interview_node',
|
|
node_id: nodeId
|
|
});
|
|
}
|
|
|
|
// Device entfernen
|
|
async removeNode(nodeId: number): Promise<void> {
|
|
return this.sendCommand({
|
|
type: 'matter/remove_node',
|
|
node_id: nodeId
|
|
});
|
|
}
|
|
|
|
// Cluster Command senden
|
|
async sendClusterCommand(
|
|
nodeId: number,
|
|
endpoint: number,
|
|
cluster: string,
|
|
command: string,
|
|
payload: Record<string, any>
|
|
): Promise<any> {
|
|
return this.sendCommand({
|
|
type: 'matter/send_command',
|
|
node_id: nodeId,
|
|
endpoint_id: endpoint,
|
|
cluster_id: cluster,
|
|
command: command,
|
|
payload
|
|
});
|
|
}
|
|
|
|
private sendCommand<T>(message: any): Promise<T> {
|
|
return new Promise((resolve, reject) => {
|
|
const id = this.messageId++;
|
|
|
|
const handler = (data: WebSocket.RawData) => {
|
|
const response = JSON.parse(data.toString());
|
|
|
|
if (response.id === id) {
|
|
this.ws.off('message', handler);
|
|
|
|
if (response.success) {
|
|
resolve(response.result);
|
|
} else {
|
|
reject(new Error(response.error?.message));
|
|
}
|
|
}
|
|
};
|
|
|
|
this.ws.on('message', handler);
|
|
this.ws.send(JSON.stringify({ ...message, id }));
|
|
});
|
|
}
|
|
}
|
|
|
|
// Beispiel: Licht steuern
|
|
const client = new MatterHAClient(
|
|
'ws://homeassistant.local:8123/api/websocket',
|
|
process.env.HA_TOKEN!
|
|
);
|
|
|
|
// OnOff Cluster Command
|
|
await client.sendClusterCommand(
|
|
1, // Node ID
|
|
1, // Endpoint
|
|
'on_off',
|
|
'on',
|
|
{}
|
|
);
|
|
|
|
// Level Control
|
|
await client.sendClusterCommand(
|
|
1,
|
|
1,
|
|
'level_control',
|
|
'move_to_level_with_on_off',
|
|
{
|
|
level: 128, // 0-254
|
|
transition_time: 10 // 1/10 Sekunden
|
|
}
|
|
);
|
|
```
|
|
|
|
---
|
|
|
|
## Thread Border Router Setup
|
|
|
|
```typescript
|
|
// Thread Border Router mit OpenThread
|
|
|
|
interface BorderRouterConfig {
|
|
networkName: string;
|
|
channel: number;
|
|
panId: number;
|
|
extPanId: string;
|
|
networkKey: string;
|
|
}
|
|
|
|
// OpenThread Border Router API
|
|
class OTBRClient {
|
|
private baseUrl: string;
|
|
|
|
constructor(host: string, port: number = 8081) {
|
|
this.baseUrl = `http://${host}:${port}`;
|
|
}
|
|
|
|
// Network Status
|
|
async getNetworkStatus(): Promise<any> {
|
|
const response = await fetch(`${this.baseUrl}/node`);
|
|
return response.json();
|
|
}
|
|
|
|
// Dataset (Network Credentials)
|
|
async getActiveDataset(): Promise<any> {
|
|
const response = await fetch(`${this.baseUrl}/node/dataset/active`);
|
|
return response.json();
|
|
}
|
|
|
|
// Neues Netzwerk erstellen
|
|
async createNetwork(config: BorderRouterConfig): Promise<void> {
|
|
await fetch(`${this.baseUrl}/node/dataset/active`, {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
NetworkName: config.networkName,
|
|
Channel: config.channel,
|
|
PanId: config.panId,
|
|
ExtPanId: config.extPanId,
|
|
NetworkKey: config.networkKey
|
|
})
|
|
});
|
|
|
|
// Thread Interface aktivieren
|
|
await fetch(`${this.baseUrl}/node/state`, {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ State: 'enable' })
|
|
});
|
|
}
|
|
|
|
// Topology abrufen
|
|
async getTopology(): Promise<any> {
|
|
const response = await fetch(`${this.baseUrl}/diagnostics`);
|
|
return response.json();
|
|
}
|
|
|
|
// External Commissioning
|
|
async startCommissioner(pskd: string): Promise<void> {
|
|
await fetch(`${this.baseUrl}/commissioner/start`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ pskd })
|
|
});
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Matter Commissioning Flow
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────────┐
|
|
│ MATTER COMMISSIONING FLOW │
|
|
├─────────────────────────────────────────────────────────────┤
|
|
│ │
|
|
│ 1. Device Discovery │
|
|
│ ├── QR Code / Manual Pairing Code │
|
|
│ ├── BLE Advertisement (für WiFi Devices) │
|
|
│ └── mDNS Discovery (Thread/Ethernet) │
|
|
│ │
|
|
│ 2. PASE (Passcode-Authenticated Session) │
|
|
│ ├── Secure Channel mit Pairing Code │
|
|
│ └── SPAKE2+ Key Exchange │
|
|
│ │
|
|
│ 3. Certificate Installation │
|
|
│ ├── Node Operational Certificate (NOC) │
|
|
│ ├── Intermediate CA Certificate │
|
|
│ └── Trusted Root Certificate │
|
|
│ │
|
|
│ 4. Network Provisioning │
|
|
│ ├── WiFi Credentials (für WiFi Devices) │
|
|
│ └── Thread Dataset (für Thread Devices) │
|
|
│ │
|
|
│ 5. CASE (Certificate-Authenticated Session) │
|
|
│ ├── mTLS mit Operational Certificates │
|
|
│ └── Secure Communication Channel │
|
|
│ │
|
|
│ 6. Device Interview │
|
|
│ ├── Supported Clusters & Attributes │
|
|
│ └── Device Type & Capabilities │
|
|
│ │
|
|
└─────────────────────────────────────────────────────────────┘
|
|
```
|
|
|
|
```typescript
|
|
// Matter QR Code Parsing
|
|
function parseMatterQRCode(qrCode: string): MatterSetupPayload {
|
|
// Format: MT:Y3.13OTB00KA0648G00
|
|
const prefix = 'MT:';
|
|
|
|
if (!qrCode.startsWith(prefix)) {
|
|
throw new Error('Invalid Matter QR code');
|
|
}
|
|
|
|
const payload = qrCode.slice(prefix.length);
|
|
|
|
// Base38 Decode
|
|
const decoded = base38Decode(payload);
|
|
|
|
return {
|
|
version: (decoded >> 0) & 0x7,
|
|
vendorId: (decoded >> 3) & 0xFFFF,
|
|
productId: (decoded >> 19) & 0xFFFF,
|
|
customFlow: (decoded >> 35) & 0x3,
|
|
discoveryCapabilities: (decoded >> 37) & 0xFF,
|
|
discriminator: (decoded >> 45) & 0xFFF,
|
|
passcode: (decoded >> 57) & 0x7FFFFFF
|
|
};
|
|
}
|
|
|
|
interface MatterSetupPayload {
|
|
version: number;
|
|
vendorId: number;
|
|
productId: number;
|
|
customFlow: number;
|
|
discoveryCapabilities: number;
|
|
discriminator: number;
|
|
passcode: number;
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Thread vs Zigbee vs WiFi
|
|
|
|
| Feature | Thread | Zigbee | WiFi |
|
|
|---------|--------|--------|------|
|
|
| **Protocol** | IPv6 native | Custom | IPv4/IPv6 |
|
|
| **Mesh** | Ja | Ja | Nein |
|
|
| **Power** | Sehr niedrig | Sehr niedrig | Hoch |
|
|
| **Range** | 10-30m | 10-30m | 30-100m |
|
|
| **Bandwidth** | 250 kbps | 250 kbps | 100+ Mbps |
|
|
| **Devices/Network** | 250+ | 65.000 | ~250 |
|
|
| **Matter Support** | Native | Via Bridge | Native |
|
|
| **Battery Life** | Jahre | Jahre | Tage-Wochen |
|
|
| **Frequency** | 2.4 GHz | 2.4 GHz | 2.4/5 GHz |
|
|
|
|
---
|
|
|
|
## Thread Credential Sharing (1.4)
|
|
|
|
```typescript
|
|
// Thread 1.4: Automatic Credential Sharing
|
|
|
|
interface ThreadCredentials {
|
|
networkName: string;
|
|
extendedPanId: string;
|
|
networkKey: string;
|
|
pskc: string; // Pre-Shared Key for Commissioner
|
|
channel: number;
|
|
panId: number;
|
|
meshLocalPrefix: string;
|
|
securityPolicy: {
|
|
rotationTime: number;
|
|
flags: number;
|
|
};
|
|
}
|
|
|
|
// Border Router synchronisiert Credentials automatisch
|
|
// Kein manuelles Übertragen mehr nötig
|
|
|
|
class ThreadNetworkManager {
|
|
private credentials: ThreadCredentials | null = null;
|
|
|
|
// Neuer Border Router joint existierendes Netzwerk
|
|
async joinExistingNetwork(borderRouterId: string): Promise<void> {
|
|
// Thread 1.4: Credentials werden automatisch geteilt
|
|
// Kein Setup von mehreren Border Routern mehr nötig
|
|
|
|
const existingRouters = await this.discoverBorderRouters();
|
|
|
|
if (existingRouters.length > 0) {
|
|
// Request Credentials vom existierenden Router
|
|
this.credentials = await this.requestCredentials(
|
|
existingRouters[0]
|
|
);
|
|
|
|
console.log('Joined existing Thread network');
|
|
} else {
|
|
// Neues Netzwerk erstellen
|
|
this.credentials = this.generateNewCredentials();
|
|
console.log('Created new Thread network');
|
|
}
|
|
}
|
|
|
|
private async discoverBorderRouters(): Promise<string[]> {
|
|
// mDNS Discovery für _meshcop._udp
|
|
// ...
|
|
return [];
|
|
}
|
|
|
|
private async requestCredentials(routerId: string): Promise<ThreadCredentials> {
|
|
// Secure request via TLS
|
|
// ...
|
|
throw new Error('Not implemented');
|
|
}
|
|
|
|
private generateNewCredentials(): ThreadCredentials {
|
|
return {
|
|
networkName: `ThreadNetwork-${randomHex(4)}`,
|
|
extendedPanId: randomHex(16),
|
|
networkKey: randomHex(32),
|
|
pskc: randomHex(32),
|
|
channel: 15 + Math.floor(Math.random() * 11), // 15-26
|
|
panId: Math.floor(Math.random() * 0xFFFF),
|
|
meshLocalPrefix: 'fd00::/64',
|
|
securityPolicy: {
|
|
rotationTime: 672, // Stunden
|
|
flags: 0xF8
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
function randomHex(bytes: number): string {
|
|
const array = new Uint8Array(bytes);
|
|
crypto.getRandomValues(array);
|
|
return Array.from(array)
|
|
.map(b => b.toString(16).padStart(2, '0'))
|
|
.join('');
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Multi-Admin (Fabric)
|
|
|
|
```typescript
|
|
// Matter Multi-Admin: Device in mehreren Ökosystemen
|
|
|
|
interface Fabric {
|
|
fabricId: bigint;
|
|
vendorId: number;
|
|
rootPublicKey: string;
|
|
label: string;
|
|
}
|
|
|
|
// Ein Matter Device kann bis zu 5 Fabrics unterstützen
|
|
const maxFabrics = 5;
|
|
|
|
// Beispiel: Gleiche Lampe in Apple Home, Google Home und Home Assistant
|
|
const deviceFabrics: Fabric[] = [
|
|
{
|
|
fabricId: 1n,
|
|
vendorId: 0x1234, // Apple
|
|
rootPublicKey: '...',
|
|
label: 'Apple Home'
|
|
},
|
|
{
|
|
fabricId: 2n,
|
|
vendorId: 0x5678, // Google
|
|
rootPublicKey: '...',
|
|
label: 'Google Home'
|
|
},
|
|
{
|
|
fabricId: 3n,
|
|
vendorId: 0x9ABC, // Home Assistant
|
|
rootPublicKey: '...',
|
|
label: 'Home Assistant'
|
|
}
|
|
];
|
|
|
|
// Alle Controller können das Gerät steuern
|
|
// Kein "Walled Garden" mehr!
|
|
```
|
|
|
|
---
|
|
|
|
## Fazit
|
|
|
|
Matter & Thread bieten:
|
|
|
|
1. **Interoperabilität**: Apple, Google, Amazon, Samsung
|
|
2. **Lokale Kontrolle**: Kein Cloud-Zwang
|
|
3. **Mesh Networking**: Zuverlässige Abdeckung
|
|
4. **Multi-Admin**: Ein Gerät, viele Ökosysteme
|
|
|
|
Die Zukunft des Smart Homes ist offen.
|
|
|
|
---
|
|
|
|
## Bildprompts
|
|
|
|
1. "Smart home devices connected via Thread mesh network, interoperability"
|
|
2. "Matter logo with connected ecosystems, Apple Google Amazon unified"
|
|
3. "Thread border router connecting mesh to home network, IoT gateway"
|
|
|
|
---
|
|
|
|
## Quellen
|
|
|
|
- [Matter Standard 2026 Review](https://matter-smarthome.de/en/development/the-matter-standard-in-2026-a-status-review/)
|
|
- [Home Assistant Matter Integration](https://www.home-assistant.io/integrations/matter/)
|
|
- [Thread Protocol Overview](https://www.home-assistant.io/integrations/thread/)
|
|
- [CSA Matter Specification](https://csa-iot.org/all-solutions/matter/)
|
|
- [Qorvo Thread/WiFi Guide](https://www.qorvo.com/design-hub/blog/simplifying-smart-homes-learn-how-matter-thread-and-wi-fi-are-revolutionizing-iot-connectivity)
|