Skip to content

Add Matter (matter.js) support: commissionable thermostat, heat pump, EVSE, smart plug, dishwasher, laundry washer, temperature & light sensors #4

Description

@HuggeK

Summary

Add Matter (smart-home standard) support to the device-simulator so the tool can emulate common Matter devices and have them paired into real ecosystems (Home Assistant, Apple Home, Google).

Implementation uses matter.js (@matter/main v0.16.x, Matter 1.4.2 spec) — the canonical, most complete Matter implementation. matter.js is Node.js/TypeScript, while this app is pure-Go single-binary, so the core work is a Go↔Node bridge that drives real, commissionable matter.js devices while conforming to the existing DeviceServer/Automatable abstraction.

Device types (all in this work)

  • Thermostat
  • Heat pump
  • EVSE charger
  • Smart plug / socket with electrical energy reporting
  • Dishwasher
  • Laundry washer (washing machine)
  • Temperature sensor
  • Light sensor

Design decisions

  • Node runtime: host-provided. Detect node on PATH (require v18+, prefer v20+). If present, Go spawns and supervises a Node child; if absent, Matter is gracefully disabled with an "install Node.js" message — never a crash. No Node bundled into the binary or Docker image.
  • Fully commissionable. Each device is a real matter.js ServerNode exposing a pairing code + QR, joinable into real fabrics. Pairing info surfaced in the UI.
  • One shared Node process hosting all Matter devices, owned by a singleton bridge manager; per-device matter.Server adapters delegate by nodeId. Auto-restart + replay on crash; persisted per-device storage so commissioning survives restarts.
  • Control channel: newline-delimited JSON over the child's stdin/stdout (mirrors the OCPP request-correlation pattern). stdout = machine frames; stderr = logs.
  • Bridge (internal/matter/bridge/) is go:embed-ed with vendored node_modules, extracted to a per-user cache dir at first run.

Integration points

New internal/matter/ Go package (manager, rpc, client, server, devicetypes, detect, storage, embed) + internal/matter/bridge/ Node program. Wiring into internal/device/device.go, internal/ports/allocator.go, cmd/simulator/main.go & app.go, profiles, frontend (stores.js, index.html), and docs-sync (openapi.json, internal/mcp/server.go, docs.html).

Testing

  • Default go test ./... stays Node-free (table tests against an in-process fake bridge; physics unit-tested in Go).
  • Real-commissioning integration tests gated behind //go:build matter_integration + skip-if-no-node.
  • Manual: pair a thermostat + smart plug into Home Assistant / Apple Home; confirm external control reflects in the simulator and survives restart.

Notes

  • Matter commissioning needs LAN multicast — works in desktop / host-network mode; Docker bridge networking will surface a warning (like the existing mDNS path).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions