Custom QA icons — how the HC3 icon system actually works, and flua's take

Fibaro has never documented how custom icons work, and the forum answers are mostly guessing. So we did what everyone else does — poked around: fetched icon files from <hc3>/assets, uploaded test sets, compared bytes, and read people's attempts on the forum, then pieced the story together. Everything below about the controller was observed that way against a 5.22x controller — treat it as "how it works on 5.22x", not a contract. flua's own parts are documented and tested.

The icon library

GET /api/icons lists every icon the controller knows:

{"device": [
  {"id": 300, "deviceType": "com.fibaro.binarySwitch",
   "iconSetName": "ButtonSwitchV2", "fileExtension": "svg"},
  {"id": 1109, "deviceType": "com.fibaro.binarySwitch",
   "iconSetName": "User1109", "fileExtension": "png"}
]}

Two families: the built-in sets (named after their device family, like ButtonSwitchV2) and custom sets — User<id>, one per uploaded icon set, with the id assigned at upload time. The deviceType says which kind of device the set was built for.

What a set must contain — the four providers

Each device type belongs to one of four providers that decide how many files a set has:

Uploading a set

POST /api/icons, multipart form: type=device, deviceTemplate=com.fibaro.binarySwitch, and one file part per provider file (icon0, icon100, …). The images must be reasonably large — 128×128 PNGs are accepted, a 32×32 was refused with INVALID_ICON_SIZE. On success:

201  {"id":1109,"iconSetName":"User1109","fileExtension":"png"}

The HC3 ships standard QuickApp functions for exactly this: QuickApp:uploadExternalIconSet(urls, options, success, error) downloads the files from a list of URLs (say, a GitHub repo) and uploads them, then sets deviceIcon to the new id itself — QuickApp:externalIconsDownload is the recursive downloader behind it.

Where the files actually live

This is the part nobody documents, and it explains most of the confusion:

Setting and switching

The device's deviceIcon property takes the icon id. The HC3 UI then switches the image per the device's state: binary types use value 0/100, multilevel types the nearest ladder step, shutters the named state. That is why a binary icon set needs two files.

Installing an icon set from a QA, idempotently

The manual flow (web UI upload + set deviceIcon) works, but a QA often wants to install its own set on first boot. The classic problem: "is my set already uploaded?" — quickVars/internalStorage go stale on reinstall and you end up with duplicate User sets.

The controller's icon library is the state you need:

  1. api.get("/icons") → entries where deviceType == self.type and iconSetName starts with User.
  2. For each candidate, download its state file(s) via net.HTTPClient from http://127.0.0.1/assets/userIcons/devices/… — the plain web server (port 80) serves the asset tree credential-free — and byte-compare with the icons you bundle.
  3. A match = already installed → just updateProperty("deviceIcon", id).
  4. No match → uploadExternalIconSet(urls, …) → new id.

Because the HC3 serves uploaded bytes verbatim, the comparison is exact — and reinstall-proof.

What flua does

flua ships the icon catalog and file manifest but not Fibaro's copyrighted artwork. flua --tool icons download fetches the images once into a machine-level cache (~/.flua/icons):

The run is incremental (--force refetches) and --dump <www> copies from a local webroot dump with no network. The web view looks ids up in /flua/iconMap (the checked-in catalog, merged with your controller's live library when running online) and fetches images from /flua/icons/…, switching state files exactly like the HC3 UI.

--%%icons:path — previewing a set without uploading

To test an icon set before it exists on any controller, point a directive at a folder that uses the upload naming:

--%%name:myqa
--%%type:com.fibaro.binarySwitch
--%%icons:icons
-- --------------- EOH ---------------

function QuickApp:onInit()
  self:updateProperty("value", false)
  setTimeout(function() self:updateProperty("value", true) end, 1000)
end
icons/icon.png        -- base
icons/icon0.png       -- off
icons/icon100.png     -- on

flua then sets the QA's deviceIcon to its own id (a fake icon id; an explicit --%%property:deviceIcon wins), registers a synthetic Local<qaId> set listing whatever the folder holds, and serves the images from the folder. Run flua myqa.lua --ui, flip value, and watch the web view switch the icons — offline, no upload, no cache. (The folder may hold any subset; only present files are listed.) The directive never travels into packed .fqa files: it is a pure preview. A runnable example ships with flua (examples/local-icons.lua, red/green/blue folder).

The whole flow: develop offline with --%%icons: → run online and download the cache once → upload the set (web UI or uploadExternalIconSet) → set the real User<id> id.

If anything here misbehaves on your firmware — or you have learned more about how the icon system really works — corrections are most welcome.