Record & replay the real house

The hardest thing to test is reality: the motion sensor that fires at 3 a.m., the lamp someone toggles during dinner, the exact timing of it all. flua can now capture that and play it back offline — record a session on your HC3, replay it against your QA in the sim, at any speed.

Record

flua record snapshots the device list and then polls the HC3's /refreshStates feed, appending every property change with a relative timestamp. It needs the usual HC3 credentials (the .env chain):

.venv/bin/flua record -o house.json --duration 60
# recorded 14 events from 188 devices to house.json

Ctrl-C stops early and still saves. The file is one JSON document: the devices (so the replay seeds the same house) and the event timeline.

Replay

Point a QA at it with --replay (or the --%%replay:house.json directive, so it can live in .flua-directives). A QA reacting to the hall lamp:

-- qa.lua
--%%name:house-react
local sub = RefreshStateSubscriber()
sub:subscribe(
  function(event) return event.data and event.data.id == 10 or false end,
  function(event) print("LAMP", tostring(event.data.newValue)) end)
sub:run()
setTimeout(function() exit(0) end, 3000)
.venv/bin/flua --replay house.json qa.lua
# [house-react5000]: LAMP true
# [house-react5000]: LAMP false

The events fire on the virtual timeline, through the same path live refreshStates take — so --speed 60 compresses a minute-long recording into a second, and --instant replays the whole session immediately. The recording also works as a plain seed (--seed house.json loads the devices without the events), and events for devices the replay run didn't seed are skipped silently.

This is the regression test you always wanted: capture the house while it misbehaves, then iterate on the QA offline against exactly what happened — deterministic, repeatable, no controller involved.

Next time: how much of the HC3 does flua actually cover — and what happens with device types it has never heard of.

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