Pacific Blue Software Logo

Making sense of the structure of the Quick Apps file in Fibaro

Investigating the structure of the Quick Apps file used by HC3

If you have ever wondered what the format of the virtual device (vfib) is then here it is. It is basically a squashed json file. JSON stands for JavaScript Object Notation and has been adopted as a standard for data swapping across platforms.


A sample of .vfib file

{
  "name": "Test_QA",
  "type": "com.fibaro.doorSensor",
  "apiVersion": "1.2",
  "initialProperties": {
    "viewLayout": {
      "$jason": {
        "body": {
          "header": {
            "style": {
              "height": "0"
            },
            "title": "quickApp_device_1726"
          },
          "sections": {
            "items": [
              {
                "components": [
                  {
                    "name": "lblStatus",
                    "style": {
                      "weight": "1.2"
                    },
                    "text": "Status",
                    "type": "label",
                    "visible": true
                  },
                  {
                    "style": {
                      "weight": "0.5"
                    },
                    "type": "space"
                  }
                ],
                "style": {
                  "weight": "1.2"
                },
                "type": "vertical"
              },
              {
                "components": [
                  {
                    "components": [
                      {
                        "name": "btnOpen",
                        "style": {
                          "weight": "0.50"
                        },
                        "text": "Open",
                        "type": "button",
                        "visible": true
                      },
                      {
                        "name": "btnClose",
                        "style": {
                          "weight": "0.50"
                        },
                        "text": "Close",
                        "type": "button",
                        "visible": true
                      }
                    ],
                    "style": {
                      "weight": "1.2"
                    },
                    "type": "horizontal"
                  },
                  {
                    "style": {
                      "weight": "0.5"
                    },
                    "type": "space"
                  }
                ],
                "style": {
                  "weight": "1.2"
                },
                "type": "vertical"
              }
            ]
          }
        },
        "head": {
          "title": "quickApp_device_1726"
        }
      }
    },
    "uiCallbacks": [
      {
        "callback": "onOpen",
        "eventType": "onReleased",
        "name": "btnOpen"
      },
      {
        "callback": "onClose",
        "eventType": "onReleased",
        "name": "btnClose"
      }
    ],
    "quickAppVariables": [
      {
        "name": "Manual",
        "type": "string",
        "value": "true"
      }
    ],
    "typeTemplateInitialized": true
  },
  "files": [
    {
      "name": "main",
      "isMain": true,
      "isOpen": true,
      "content": "function QuickApp:onOpen ()\n
      self:updateView ('lblStatus', 'text',  'Open')\nend\n\n
      function QuickApp:onClose ()\n  self:updateView ('lblStatus', 'text',  'Close')\n
      end\n\nfunction QuickApp:onInit()\n    self:debug(\"onInit\")\nend\n"
    }
  ]
}

Summary

This is a 3 row user interface with a block of main code and a block of code for a button :

Sample Code

Here is the Lua code expanded.

    function QuickApp:onOpen ()
      self:updateView ('lblStatus', 'text',  'Open')
    end

    function QuickApp:onClose ()
      self:updateView ('lblStatus', 'text',  'Close')
    end

    function QuickApp:onInit()
      self:debug("onInit")
    end
    

Dissecting the structure of the .fqa file


Back to Articles for Developers
Back to Articles on Lua
A Sample class in Lua for the HC3

If you found this useful, then please consider making a donation.

paypal
QR Code for donation Please donate if helpful