Test foreign QAs without touching them

You download someone's QA from the forum. It has their IP, their password, their names baked into the --%% header. You want to run it with your values — without editing the file (you want to send it back, or update it later). Until now that meant -D flags in a launch config, or worse, editing the QA and forgetting.

flua's answer is a file: .flua-directives, sitting next to the QA's main file. It uses the exact same --%% syntax as a QA header, and it wins over the QA's own directives. Drop it in the directory, press F5 — no launch.json edits, no QA edits.

The foreign QA

Say the QA looks like this (their values, not yours):

-- foreign.lua — someone else's QA, do not edit
--%%name:remote-lamp
--%%var:host="192.168.1.10"
--%%var:pwd="hunter2"
print("RUN")
setTimeout(function()
  local dev = api.get("/devices/".._FLUA.qaId)
  for _, qv in ipairs(dev.properties.quickAppVariables) do
    print("VAR", qv.name, qv.value)
  end
  exit(0)
end, 10)

Run it as-is:

.venv/bin/flua foreign.lua
# [remote-lamp5000]: RUN
# [remote-lamp5000]: VAR pwd hunter2
# [remote-lamp5000]: VAR host 192.168.1.10

Your override file

Next to it, create .flua-directives — same syntax as a QA header. Expressions work too: os.getenv reads your .env chain, so the file itself can stay secret-free:

-- .flua-directives — next to foreign.lua
--%%var:host="10.0.0.99"
--%%var:pwd=os.getenv("HC3_TEST_PWD")
HC3_TEST_PWD=s3cret .venv/bin/flua foreign.lua
# [remote-lamp5000]: VAR host 10.0.0.99
# [remote-lamp5000]: VAR pwd s3cret

The QA's own header still wins nothing — the file overrides it, per key. An explicit -D flag still beats the file, so a one-off experiment doesn't require editing anything:

.venv/bin/flua -D 'var:host="11.0.0.1"' foreign.lua
# [remote-lamp5000]: VAR pwd s3cret
# [remote-lamp5000]: VAR host 11.0.0.1

The full precedence chain

Discovery keys on the directory of the file you pass on the command line — for a .fqa, the package's own directory, never inside it. A missing file is simply skipped. Several QAs in different directories each get their own overrides; a QA in the same directory shares yours.

Next time: all of this grew a UI — the flua VS Code extension packs, unpacks, checks, and uploads from the explorer.

.flua-directives: USAGE.md · pip: fibaro-flua 0.1.83 · flua: https://github.com/jangabrielsson/flua