HA-Bridge is often used for turning devices off and on or dim lights using the following API calls:
On Items Command Group: http://user:
[email protected]/api/callAction?deviceID=322&name=turnOn
Off Items Command Group: http://user:
[email protected]/api/callAction?deviceID=322&name=turnOff
Dim Items Command Group: http://user:
[email protected]/api/callAction?deviceID=322&name=setValue&arg1=${intensity.percent}
It can also be used to set sliders on Virtual Devices, as I've done in my Alexa Heating Override VD (Topic 25381) using this API call:
http://user:
[email protected]/api/callAction?deviceID=358&name=setSlider&arg1=1&arg2=${intensity.percent}
And another common use-case is to call a scene, which can use either of the following API calls:
http://user:
[email protected]/api/scenes/56/action/start
http://user:
[email protected]/api/sceneControl?id=56&action=start
However, the Scene Action API also allows parameters (arguments) to be sent to the scene, by embedding a json message in the HTTP body as an array of values. To start a scene from HA-Bridge and send parameters, then setup the device in HA-Bridge as follows:
Type: HTTP Device
Target Item: http://<HC IP Address>/api/scenes/<nn>/action/start
HTTP Verb: POST
HTTP Body: {"args":["ABCDE", 12345]}
HTTP Header: [{"name":"Authorization","value":"Basic ZGF2ZTpteXBhc3N3b3Jk"}]
Content Type: application/json
Where <nn> is the scene number, eg:
http://192.111.111.111/api/scenes/56/action/start
And the value in the HTTP Header after the word 'Basic' is your Fibaro user id and password separated by a colon, and encoded in Base64. Use a site, such as https://www.base64encode.org/ to do this encoding for you. So for example:
dave:mypassword
becomes:
ZGF2ZTpteXBhc3N3b3Jk
It seems that it's necessary to send the userid and password using this method, rather than the more commonly seen method of adding the credentials before the Fibaro IP address, otherwise an error (HTTP 405) is returned by Fibaro.
The HTTP Body contains the json with the list of parameters in an array. So if you want to pass in, let's say, a device number and the 'lux' value, then you could send something like this:
{"args":[345, ${intensity.percent}]}
In the scene, you can fetch the parameters using the fibaro:args() function, eg:
local args = fibaro:args()
if (args ~= nil) then
for key,value in pairs(args) do
fibaro:debug(value)
end
end
Dave