Note: hub-aware completions in the VS Code extension (design draft)

Status: v1 implemented (2026-11-08) — flua --tool house, the completions provider in the VS Code extension (vscode/src/completions.ts), the flua.house.refresh/flua.house.generateHomeTable commands, and the flua.houseDb/flua.houseRefresh settings. Stretch items (live refresh against a running emulator, room filters, ht.lua regeneration) remain.

Context and goal

Magic numbers are the biggest friction in fibaro.* calls: fibaro.call(45, "turnOn") says nothing about what device 45 is. A developer in the HC3 web editor can look up the ID, but in VS Code the number is just a number. This note designs completions that carry the data — device IDs with names and rooms, global variable names, scene IDs, custom event names, and a HT.kitchen.light home table — through the existing flua VS Code extension. One edge worth claiming: the data can also come from the simulated house (db/seed file), so completions work fully offline — or for a house that does not exist yet.

What exists today (verified)

Design

Data source: one new CLI command

flua --tool house --json prints a stable shape:

{
  "devices": [{"id": 45, "name": "Kitchen light", "room": "Kitchen", "type": "com.fibaro.binarySwitch"}],
  "globals": ["AlarmState", "Presence"],
  "scenes": [{"id": 3, "name": "Evening lights"}],
  "customEvents": ["DoorOpened"]
}

Resolution order:

  1. HC3 credentials present (the .env chain) → fetch from the hub (online mode, the same path downloadQA/uploadQA use).
  2. Else a db/seed file (a new flua.houseDb extension setting, or the workspace's .flua-directives --%%db:) → load the sim state, the same logic as --tool state.
  3. Else empty — a QA-only run has no house, and an empty list is honest.

The tool is the single choke point: the provider never talks to a hub or the sim directly, so credential handling and offline behavior stay in one place (and agents/CI get the same JSON for free).

Completions provider (extension side)

One new file vscode/src/completions.ts:

Stretch (not v1)

Alternatives considered

v1 scope

  1. flua --tool house --json (hub or db/seed) with a pinning test for the JSON shape.
  2. vscode/src/completions.ts — the four contexts above.
  3. flua.generateHomeTable + flua.refreshHouse commands, the flua.houseDb/flua.houseRefresh settings.
  4. Docs: USAGE.md (--tool house) and the extension README.