Communication examples
This page provides basic examples for essential communication operations of SOL Lighting Management System.
OpenDAF provides communication API via RESful API and WebSocket. All described operations can be accessible via both.
We will use for this example generalized SOL-Object
, which can represent any of the SOL Objects as is Ballast, Group or Digital I/O.
Measurement/s read example
Measurement can be considered as output of SOL-Object
s' property, like Temperature, Setpoint or Alive status.
HTTP API
We need to perform GET
request to read measurement's value. General request looks following:
GET http://<sol-address>/opendaf/measurements/<measurement-name>
where measurement-name is name of measurement we want to read. For list of accessible SOL-Object
names see Object classes description.
Example:
To read Ballast's RC module temperature on an Ballast with address 00:0E:94:03
we need to execute the following request:
GET http://<sol-address>/opendaf/measurements/M_BALLAST_00_0E_94_03_RC_T
With response corresponidng to measurement.json schema:
{
"name" : "M_BALLAST_00_0E_94_03_RC_T",
"address" : "mv 00:0E:94:03/t",
"datatype" : "i",
"raw-datatype" : "i",
"eu-range" : [null,null],
"raw-range" : [null,null],
"vtq" : ["i35",[1643723135,296735],192]
}
For detailed informations see RESTful API documentation.
WebSocket
Above examples can be done WebSocket's way with target to receive measurement's update notifications on every measurement change. First we need to connect to WebSocket hosted on:
http://<sol-address>/opendaf/ws/opendaf
Then it's required to send WatchMeasurements request witch requested measurement names to WS in order to register for update notifications. For detailed informations about WebSocket communication see WebSocket API documentation.
Command/s write example
Command can be considered as input if SOL-Object
s' property, like Setpoint set, On/Off property etc.
HTTP API
To write a Command we need to perform PUT
request on command name. General request looks following:
PUT http://<sol-address>/opendaf/commands/<command-name>?value=<prefixed-value>
where command-name
is name of command we want to write and prefixed-value
is value we want to write prefixed with it's datatype. For list of accessible SOL-Object
names see Object classes description.
Example:
To set Primary Setpoint on Ballast with address 00:0E:94:03
to 70% we need to execute the following request:
PUT http://<sol-address>/opendaf/commands/C_BALLAST_00_0E_94_03_SP_P_SET?value=i70
For detailed informations see RESTful API documentation.
WebSocket
Above examples can be done WebSocket's way. First we need to connect to WebSocket hosted on:
http://<sol-address>/opendaf/ws/opendaf
Then it's required to send WriteCommands request witch requested command names to WS. For detailed informations about WebSocket communication see WebSocket API documentation.