Please add your own knowledge if it is missing from this overview!

The basic stuff Edit

The following functions are covered by the online documentation, provided by Fibaro:

Device control Edit

  • fibaro:call(deviceID, actionName*, ...)
  • fibaro:get(deviceID, propertyName*)
  • fibaro:getValue(deviceID, propertyName*)
  • fibaro:getModificationTime(deviceID, propertyName*)
  • fibaro:getType(deviceID)
  • fibaro:getRoomID(deviceID)
  • fibaro:getSectionID(deviceID)
  • fibaro:getDevicesId(filters)
  • fibaro:callGroupAction(action, filters)

* Possible actionNames or propertyNames can be discovered by the right mouse button menu while editing luacode in a Virtual Device or in the left menu while editing a lua scene.

Scene (lua) control Edit

  • fibaro:abort()
  • fibaro:getSourceTrigger()
  • fibaro:getSourceTriggerType()
  • fibaro:startScene(sceneID)
  • fibaro:killScenes(sceneID)
  • fibaro:setSceneEnabled(sceneID, enabled)
  • fibaro:isSceneEnabled(sceneID)
  • fibaro:countScenes()
  • fibaro:countScenes(sceneID)
  • fibaro:setSceneRunConfig(sceneID,runConfig)
  • fibaro:getSceneRunConfig(sceneID)

Global variables management Edit

  • fibaro:getGlobal(varName)
  • fibaro:getGlobalModificationTime(varName)
  • fibaro:getGlobalValue(varName)
  • fibaro:setGlobal(varName, value)

Additional functions Edit

  • fibaro:calculateDistance(position1, position2)
  • fibaro:debug(text)
  • fibaro:sleep(timeInMilliseconds)
  • HomeCenter.SystemService.reboot()
  • HomeCenter.SystemService.shutdown()

Plugins control Edit

(Functions that are usefull when writing Addons)

  • ...
  • net.HTTPClient
  • net.HTTPClient.request(url, options, succes, error)

Popup service Edit

This function is used for creating pop-ups to be displayed on mobile devices. This way you can get a customizable notification of any event and/or trigger a scene using the button located in the pop-up window.

  • HomeCenter.PopupService.publish({title, subtitle,contentTitle, contentBody, img, type, buttons})

Notifications control Edit

This function is used to create notifications that are only visible on the web interface of the HC2 (Configuration -> Notification Center)

  • HomeCenter.NotificationService.publish(payload)
  • HomeCenter.NotificationService.update(id, payload)
  • HomeCenter.NotificationService.remove(id)

Other functions Edit

Other functions, not covered in the documentation:

The REST api Edit

More functionality is accessible through the REST api of the Home Center 2. Those possibilities are also covered in the documentation online. You can even use the REST api in lua scenes or virtual devices.

An other source of the REST api at work is your own HC2 by surfing to <HC2ipAdres)/docs.

Using the REST API in scenes Edit

Accessing the REST api in a scene is done by the following functions:

api.put(url, payload), payload)
api.delete(url) ? 

example: local location = api.get('/settings/location')

Using the REST API in Virtual Devices Edit

Accessing the REST API in a virtual device is done with the following code:

local HC2 = Net.FHttp('', 11111)
local response, status, errorcode = HC2:GET('/api/settings/location')
local location = json.decode(response)
'' is the localhost (your HC2)
11111 is a port that requires no authentication, if called from the localhost.

Fetching other urls online Edit

Fetching urls from other websites (and there api) can be done in as follows.

Fetching urls from a scene Edit

can be used to fetch http and https.

example: fetching the rain radar predictions for Brussels

local http = net.HTTPClient({1000})  
local url = ''
http:request( url, { success = function(response) fibaro:debug(response) end } )

Fetching urls from a Virtual Device Edit

can only fetch http but no https.

example: fetching the weather forecast from open weather map

local OpenWeatherMap = Net.FHttp(
local url = '/data/2.5/forecast?lat=50.84667&lon=4.35472&units=metric'
url = url ..'&cnt=8&appid=b6907d289e10d714a6e88b30761fae22'
response, status = OpenWeatherMap:GET(url)
local forecast = json.decode(response)

Other useful functions Edit

json Edit

The following json functions could come handy:

local text  = json.encode(table)
local table = json.decode(text)