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.
{
"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"
}
]
}
This is a 3 row user interface with a block of main code and a block of code for a button :
items
is an array of visual elements, in this case two of them.
components
is an array of items on that row, for the button row, there
are two buttonsquickAppVariables
is an array of variables declared in the interface.
In this case there is one called manual of type string and value 'true'.content
is the actual Lua code for the whole QuickApp. Lines are separated with `\n`.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