Note: device schemas — type composition, interface semantics, property type checks (plan)

Status: implemented 2026-11-10 — phases 0–2 done (extraction + artifact, schema-first skeletons + interface semantics + --%%interface:, and the warn-only property type/enum checks). ADR 0014 is the decision record; phase 3 (catalog/template verification, device-specific types feeding the catalog) stays unplanned.

Context and goal

Original HC3 sources now live locally (gitignored, HC3_info/): 189 device-type XMLs (types/), 130 interface XMLs (interfaces/), and 1173 property JSON schemas (www/json-schema/). The type XML declares the base-type chain, the interfaces a device gets, typed properties with defaults (and jsonSchema refs), and actions with arity; the interface XML declares the properties/actions an interface adds; the JSON schemas carry the enums (e.g. deviceRole). Today flua ignores all of it: device skeletons come from a hand-curated hierarchy fallback (devices/hierarchy.json + skeleton_for), interfaces are stored with no semantics (ADR 0012), there is no --%%interface: directive, and property types are unchecked anywhere.

The goal: preprocess the XML/JSON into flua's own compact schema artifact, shipped in the wheel, and drive device-structure setup from it — type composition on --%%type:/POST /devices, interface add/remove semantics (--%%interface:, POST /plugins/interfaces), and property type checks (runtime warnings + static flua --check).

The access constraint shapes the architecture: the sources stay gitignored and are never shipped; only the distilled schema (facts flua needs, in our format) is committed. That is also technically the right format: smaller, faster, no XML parsing at runtime.

Phase 0 — extraction

scripts/extract_device_schemas.py (precedent: extract_icons.py, extract_hc3_api.py) reads HC3_info/{types,interfaces}/*.xml and HC3_info/www/json-schema/properties/*.json, resolves the jsonSchema refs into inline enums, and emits src/flua/devices/type_schemas.json:

{
  "types": {
    "com.fibaro.binarySwitch": {
      "baseType": "com.fibaro.actor",
      "interfaces": ["light", "autoTurnOff"],
      "properties": {
        "value": {"type": "bool"},
        "deviceIcon": {"type": "int", "default": 301},
        "deviceRole": {"type": "string", "enum": ["Light", "Other", ...]}
      },
      "actions": {"turnOn": {"argc": 1}, "turnOff": {"argc": 1}}
    }
  },
  "interfaces": {
    "autoTurnOff": {
      "properties": {"autoOffTimestamp": {"type": "int", "default": 0},
                     "autoOffDefaultTime": {"type": "int", "default": 900}},
      "actions": {"setAutoOff": {"argc": 3, "args": [{"name": "time", "type": "int"}]}}
    }
  }
}

Open: is the extraction script itself committed (pure logic, no data — leaning yes), or kept local alongside the sources?

Phase 1 — type composition + interface semantics

Phase 2 — property type checks

Phase 3 (later, unplanned now)

Known type-system oddities (mined 2026-11-10)

The 15-year-old type system is cleaner than expected, with drift concentrated in a few places:

Open questions

  1. Commit the extraction script? (pure logic, no data — leaning yes; the alternative keeps every trace of the sources local)
  2. Enums in v1? They make both type checks real (deviceRole's list is big) at the cost of artifact size — leaning yes, they're the value.
  3. Runtime type mismatch: confirm warn-only (never reject)?
  4. Scope of types in v1: the generic com.fibaro.* set only, or the device-specific files (FGD212, FGBS222, ...) too?
  5. Action argc: metadata only in v1, or should the sim validate fibaro.call argument counts against it (warn)?