When you design a QuickApp UI in the HC3's visual editor, there is a
button that exports the view as a uiView JSON structure — the
modern, second way to describe a QuickApp interface, next to the legacy
$jason viewLayout. The exported struct is meant
to be pasted into createChildDevice's
initialProperties.uiView, and it is clearly a format Fibaro
plans to keep: the editor itself writes it, and it must stay backward
compatible.
What Fibaro has not published is documentation of the format. This post is our reverse-engineered field guide — everything below comes from black-box observation of firmware 5.221, our own controllers, and reading the app's behavior. Treat it as our best guess. If you know better, correct us in a comment and we'll update the post (and flua).
A uiView is a list of rows. Each row is a container
("type": "horizontal" or "vertical") holding a
components list. Every component carries at least a
name, a type, and a style object:
[
{ "type": "horizontal", "style": {"weight": "1.0"}, "components": [
{ "name": "lbl", "type": "label", "text": "Hello", "visible": true,
"style": {"weight": "1.0", "textAlign": "left"}, "classes": [] },
{ "name": "btn", "type": "button", "text": "Go", "visible": true,
"style": {"weight": "0.5", "color": ""}, "classes": [],
"eventBinding": { "onReleased": [
{ "type": "deviceAction", "params": { "actionName": "press", "args": [] } } ] } }
]}
]
Names must be unique — events route by element name, and duplicates
collide. visible is a boolean. Unknown fields are simply
ignored by the app.
style.weight (a string, like "1.0" or
"7") is the element's share of its container: inside a
horizontal row it shares the width among siblings; inside a
vertical container it shares the height. The catch we verified the
hard way: the split only happens in fixed-height layouts. A QA's
UI is auto-height, so a lone element's weight changes nothing — that's
why weight=7 on an image did not make it taller on the
controller. Weight never changes text size either.
"left"/"center"/
"right" on a label positions its text across the row.
Verified working.An element's classes array reaches the rendered
component, and the app switches behavior on specific names. Two rules
save most of the confusion: a class only changes something when the
element has the right shape (an icon, a value binding, min/max), and the
layout classes below belong on the container row, not on
the elements inside it. The ones we have found and tested — several
verified against the app's own bundled views (ui-views/)
and component CSS:
title, labelXXL — bigger, bold,
primary color (verified).textPositionBelow stacks the
control's visual above its text — with no icon/image there is
nothing to stack, so a plain text button looks unchanged (the app's own
showcase uses it on a switch, "Power below"). toggle is a
switch class — see the built-in autoTurnOff
interface — on a plain button it does nothing.
circle/squircle sit in the app's sizing code
but did nothing on a plain button for us — probably icon-button
territory.thick (the big thumb),
vertical (column direction), minMaxWords
("min"/"max" words at the ends — and it switches to the thin style),
invertFill (fill direction), iconsMinusPlus
(minus/plus icons at the ends — the app pairs it with
thick), slatsAngle (the blinds-like fill
angle), and timer (an elapsed-time readout above the
slider). Most need a proper slider shape — min/max/value bound; the app's own multilevelSwitch slider is the template:
{ "name": "setValue", "type": "slider", "min": "0", "max": "100", "step": "1",
"value": "{{device.properties.value}}", "unit": "%",
"style": { "weight": "1" }, "classes": ["thick", "iconsMinusPlus"],
"eventBinding": { "onChanged": [{ "type": "deviceAction",
"params": { "actionName": "setValue", "args": ["$event.value"] } }] } }
imageS/imageM/imageL —
fixed 32/40/48px squares.horizontal/
vertical row itself: glued (zeroes the gap
between the row's children), panel (a boxed card: padding,
rounded corners, border, background), dividers (children
become list rows with separator lines), and borderTop/
borderBottom (a hairline above/below the row).The grey horizontal separator line: a component of
type: "space" with classes: ["borderTop"]. The
app draws its .spacer-line for exactly that. It is a v2
feature — with useUiView: false the legacy renderer draws
nothing, unique names or not (verified).
An image is {"name", "type": "image", "url", "useProxy"}.
useProxy: true routes the URL through the controller's
plugin proxy — needed for plugin-relative paths and remote camera access,
pointless for a public https:// URL. The element renders
max-width:100%; height:auto: natural aspect, capped by the
container width. To make a picture taller, use a portrait source.
The quirk: to change the picture at runtime you must
self:updateView(elm, "source", url) — "source"
is the image element's legacy update property, which the HC3 remaps to
the url. "url" does nothing. And updateView never touches
the declared struct: the device's uiView keeps the old url, the update
lives in live render state. You can see that state yourself:
GET /plugins/getView?id=<id> returns the
rendered view with updates merged (and the app's own defaults
filled in), while /devices/<id> only shows the
declared uiView. Declared vs rendered — two layers, one UI.
The v2 format binds events on the element itself instead of the
separate uiCallbacks table:
"eventBinding": { "onReleased": [
{ "type": "deviceAction", "params": { "actionName": "press", "args": [] } }
] }
For a child device the actionName is your Child class method
and args is a JSON array — argless calls must use a real
array (json.array() in Lua); a plain {} encodes
as an object and the app silently drops the action. For a main QA
the binding is "type": "UIAction" and the good old
uiCallbacks table still does the routing. See our earlier
post The button that did
nothing for the full model.
onTabChanged binding.collapsed toggles at runtime).borderTop.flua compiles the same format from your QA file, so everything above is one directive away:
--%%u:{label="lbl",text="Hello",textAlign="center"}
--%%u:{{button="a",text="A",onReleased="go",color="#2e9e5b"},{button="b",text="B",onReleased="go"}}
--%%u:{space="div1",classes={"borderTop"}}
--%%u:{vertical="col",classes={"panel","dividers"},components={{{label="a",text="A"}},{{button="b",text="B",onReleased="go"}}}}
--%%rsrc:childUI:{image="art",url="https://host/art.png",classes={"imageL"}}
The visual uibuilder (post 37) can build all of this in the browser and exports the directives. flua's own viewer mirrors the format — with the same declared-vs-live split, so your QAs behave alike in the sim and on the controller.
Our best guess, as always — corrections and additions welcome in the comments · related posts: Design your QuickApp UI in the browser, Child UIs as resources, The button that did nothing · flua: https://github.com/jangabrielsson/flua