Free@home local API concepts
free@home local API model
The free@home API provides endpoints to request the current configuration or data model. Additional endpoints allow to get and set datapoints which represent the current state of the devices in your smart home.
With a WebSocket connection the application can be informed about changes to the model or datapoints without polling.
Then there is a endpoint to register virtual devices on the ABB-free@home smart home system that represent 3rd-party hardware.
Data model
The data model consists of the different ABB-free@home smart home systems (also called SysAP) that are registered for the same ABB-myBuildings Account. The SysAPs are identified by their UUID or Site ID. Most endpoints return a JSON-Object where the SysAP-UUID is the key for the response object from this SysAP.
A simplified response from the configuration
endpoint looks like this:
{
"00000000-0000-0000-0000-000000000000": {
"sysapName": "my little SysAP",
"devices": {
"BEED2CD50001": {
"displayName": "Dimmable lamp",
"floor": "04",
"room" : "01",
"channels": {
"ch0000": {
"displayName": "Dimmable lamp",
"floor": "04",
"room" : "01",
"functionID": "0012",
"inputs": {
"idp0000": { "pairingID": 1, "value": "1" },
"idp0001": { "pairingID": 16, "value": "50" }
}
"outputs": {
"odp0000": { "pairingID": 256, "value": "0" },
"odp0001": { "pairingID": 272, "value": "0" }
}
}
}
}
}
"floorplan": {
"floors": {
"04": {
"name":"First floor",
"rooms": {
"01": {
"name":"Office"
},
"02": {
"name":"Kitchen"
}
}
}
}
}
}
}
In this shortened example you see:
- There is a single SysAP sending its data model.
- That model consists of devices (here only one). A device in the data model matches a real hardware device that is connected to the SysAP either via cable or via radio (with the special-case of virtual devices for advanced use-cases, as discussed further below), for example a light switch/actuator device.
- The device consists of channels. A channel represents some kind of function of the device, such as
“switch” and “light”, that can be controlled separately. Some devices have multiple channels which
may be mutually exclusive, depending on the device.
See the section on Devices and Channels for details. - Each channel is made of input and output datapoints. A datapoint represents some kind of data that
can be sent to the device (input datapoint), such as “switch on/off”, or that can be read from the
device (output datapoint), such as “light is currently on/off”.
See the section on Input and output datapoints for details.
Devices and Channels
The channels in the devices are used to establish specific applications like
switching and dimming etc. A device with multiple functions has multiple
channels.
Both devices and channels have attributes like displayName
, floor
and room
that often, but not always have the same values. In most cases you should use the values
from the channel. For example a 4-channel switching actuator may have its
different outputs in different rooms.
Note that the floor
and room
attributes may be
missing when the user has not set a location in the free@home configuration (device/channel is not
“placed”).
Devices are identified by their ID or serial, in the example above: BEED2CD50001
.
Channel IDs are numbered with a prefix of ch
. Both IDs are used as keys in
the hashmaps under devices
and channels
. Note that the Channel ID is actually a hex number,
not a decimal number, i.e. a value of ch000a
is valid.
The meaning of a channel is given by the attribute functionID
that is given as
a 4-digit hexadecimal number.
In the example the device BEED2CD50001
has only one channel (ch0000
) with
the functionID
of "0012"
which represents a Dimming actuator.
Here are some commonly used possibly values:
Function ID | Name | Description |
---|---|---|
0x0000 | FID_SWITCH_SENSOR |
Control element |
0x0001 | FID_DIMMING_SENSOR |
Dimming sensor |
0x0003 | FID_BLIND_SENSOR |
Blind sensor |
0x0007 | FID_SWITCH_ACTUATOR |
Switch actuator |
0x0009 | FID_SHUTTER_ACTUATOR |
Blind actuator |
0x000A | FID_ROOM_TEMPERATURE_CONTROLLER_MASTER_WITH_FAN |
Room temperature controller with fan speed level |
0x000B | FID_ROOM_TEMPERATURE_CONTROLLER_SLAVE |
Room temperature controller extension unit |
0x0012 | FID_DIMMING_ACTUATOR |
Dim actuator |
0x0023 | FID_ROOM_TEMPERATURE_CONTROLLER_MASTER_WITHOUT_FAN |
Room temperature controller |
0x0061 | FID_BLIND_ACTUATOR |
Roller blind actuator |
0x0062 | FID_ATTIC_WINDOW_ACTUATOR |
Attic window actuator |
0x0063 | FID_AWNING_ACTUATOR |
Awning actuator |
0x4000 | FID_LightGroup |
Light group |
0x4001 | FID_DimmerGroup |
Dimmer group |
0x4A00 | FID_TimerProgramSwitchActuator |
Timer program switch actuator |
Please refer to the reference documentation for a complete list.
Input and output datapoints
The datapoints represent the internal state of the devices.
Input and output is meant from the perspective of the device:
Setting new values to an input datapoint will change the state and will be
represented by changed output datapoint values.
Input datapoints are used to control the device and
output datapoints are the feedback datapoints
that show the current condition in which the device is.
The input and output datapoints can be distinguished by their prefix
idp
and odp
. Please note that the number after idp
and odp
in the datapoint ID is a
hexadecimal number, i.e. a value of ipd000a
is valid.
You can use the pairingID
to determine the semantic for a datapoint.
This pairingID
also define values or value types you can write to a datapoint.
For reading and writing datapoints the value is always encoded as string.
In the example above the first input datapoint (idp0000
) has a pairingID
of 1
, which specifies a On/Off switch.
Here are some commonly used values for pairing IDs:
Pairing ID | In/Out | Description | Value |
---|---|---|---|
1 | in | Switch On/Off | 0 - Off 1 - On |
17 | in | Absolute control of the set value | percent from 0 to 100 |
32 | in | Move sunblind up / down | 0 - up 1 - down |
33 | in | Stops the sunblind and to step it up/down | 0 |
35 | in | Moves the sunblinds into a specified position | position from 0 to 100 percent |
51 | out | Defines the displayed set point temperature of the system | temperature in °C |
54 | out | states: on/off; heating/cooling; eco/comfort; frost/not frost | bitmask: 0x01 - comfort mode 0x02 - standby 0x04 - eco mode 0x08 - building protect 0x10 - dew alarm 0x20 - heat (set) / cool (unset) 0x40 - no heating/cooling (set) 0x80 - frost alarm |
56 | out | Switches controller on or off. Off means protection mode | 0 - off (Protection mode) 1 - on (Comfort mode or Eco mode) |
58 | in | Switches eco mode on or off | 0 - off 1 - on |
66 | in | Request for switching controller on or off. Off means protection mode | 0 - off (Protection mode) 1 - on (Comfort mode or Eco mode) |
256 | out | Info On/Off | 0 - Off 1 - On |
272 | out | Info Actual dimming value | brightness from 0 to 100 percent |
288 | out | indicate the move up/down and stop state | 0 - not moving 2 - moves up 3 - moves down |
289 | out | Indicate the current position of the sunblinds in percentage | position from 0 to 100 percent |
320 | in | Absolute set point temperature input for timer | temperature in °C |
Please refer to the reference documentation for a complete list.
Scenes
A SysAP supports configuration of scenes as a way to set multiple datapoints to a configured value by activating a single switch. Common use-cases are “all lights off”, or e.g. “dim living room lights to 50%” etc.
A scene in the datamodel of the SysAP is represented as a device with a channel with function ID “4800” (0x4800).
However while these special scene devices may be included in the datamodel, they can currently not be controlled directly by the free@home local API: The configuration of scenes is handled completely by the SysAP. The intended way to activate a scene using the free@home local API is to pair the scene with a switch in the SysAP configuration and then activate the switch.
Note that using a virtual device instead of a hardware device is possible, however setting up a virtual device is an advanced concept and may be overkill for this use-case.
Websocket
The free@home local API provides a websocket endpoint to enable the API user to get immediately informed about changes to datapoints or the configuration without polling.
In order to open a websocket, you require a websocket implementation that:
When these requirements are ensured, simply open a websocket with the correct authentication headers.
on the websocket url (using the usual websocket schema wss://
instead of https://
):
wss://{IP-Address of the Sysap}/fhapi/v1/api/ws
After this, you can receive websocket events on the opened websocket connection. Note that sending commands over the websocket is not possible, simply use the normal REST API instead.
See the samples for an example.
Websocket events
After connecting to the websocket, all events in the free@home smart home system will be sent on the websocket as JSON objects. Each websocket frame will contain one JSON object.
An event looks like this:
{
"00000000-0000-0000-0000-000000000000": {
"configDirty":"false",
"datapoints":{
"ABB70000098B/ch0000/odp0000":"1",
"ABB70000098B/ch0006/idp0000":"1"
},
"scenesTriggered": {},
"devices":{},
"devicesAdded":[],
"devicesRemoved":[],
"timestamp":"2019-09-05T12:54:14.992Z"
}
}
In this event two datapoints were changed and their new values are notified.
Changing attributes of devices and/or adding/removing devices will be
notified in the devices
, devicesAdded
and devicesRemoved
attributes.
The latter two attributes only contain the device serials. But the devices
attribute contains the whole configuration for the new/modified device like in
JSON returned by the configuration
endpoint.
Websockets will always send all events from the SysAP.
Virtual devices
There is a REST endpoint to register a virtual device in the free@home smart home automation system. The API user can use this to create a proxy device in free@home for a hardware device operated outside of the free@home smart home system. For example you can register a garage door opener in your home automation system as virtual device to control and monitor it from there.
To register a virtual device to a sysap you need the SysAP ID
to identify
the SysAP where you will register the virtual device.
As second parameter a Native ID
to uniquely identify the device in this and
subsequent calls.
Additional parameters are given as JSON in the request body.
This object may look like:
{
"type": "SwitchingActuator",
"properties": {
"ttl": "180",
"displayname": "Virtual switch"
}
}
In this request object you can give a type
to specify the device type of
the new virtual device.
Check the table below for possible device types.
The value of displayname
is the friendly name shown to the user.
The value of ttl
is a decimal string that specifies the
Time to live in seconds.
Valid values are from 180 to 86400 seconds, i.e. 3 min to 24 hours.
After this time you need to re-register the virtual device.
If you fail to re-register the virtual device before the TTL expires the
device is marked as unresponsive in the free@home smart home automation
system.
This is retracted when a new lifesign is send by calling the endpoint to
register a virtual device again.
If you omit the ttl
parameter it defaults to 180 seconds.
A TTL value of 0
immediately marks the device as unresponsive.
As the return value the endpoint will return the serial used by the
free@home automation system to identify the virtual device.
Note that this serial ID is different from the native ID.
You will find the nativeId
in the data model as attribute on virtual devices.
Another attribute to identify virtual device in the data model is the
interface
attribute whose value have a prefix of "vdev:"
.
After the registration you will be informed via the WebSocket of the new
device and it will be returned by the configuration
endpoint.
The available channels and input and output datapoints will depend on the
specified device type.
Please remember that input and output datapoints are named from the
perspective of the device.
This means that the API user has to write to the output datapoints that are
the feedback datapoints to show the current state of the virtual device.
The input datapoints for a virtual device are used to control it and
change its current state.
The owner of the virtual device has to monitor the input datapoints for its
virtual devices to react to these changes and
use it to control the hardware device.
Life-cycle of a virtual device
The virtual device is created via the first call to the
api/rest/virtualdevice
endpoint.
The JSON object in the request body is required to contain the type
value and
can contain the other properties like ttl
and displayname
.
Then before the TTL from the previous call is expired the api user needs
to call the endpoint again.
But in this case you can omit all parameters with the exception of the
two path parameters (SysAP ID
and Native ID
).
The TTL value will be the default (3 minutes) in this case.
To mark a virtual device as unresponsive in the free@home automation system
re-register it with a TTL value of 0
.
An unresponsive device can be removed by the enduser.
Device type
The type
parameter in the request object can be one of the following values:
Device Type |
---|
BinarySensor |
WindowSensor |
CeilingFanActuator |
DimActuator |
ShutterActuator |
SwitchingActuator |
RTC |
CODetector |
FireDetector |
Weather-BrightnessSensor |
Weather-RainSensor |
Weather-TemperatureSensor |
Weather-WindSensor |
WeatherStation |
See here for an example.
Scene support for virtual devices
As all devices in ABB-free@home smart home system the virtual devices created by
calling the virtualdevice
endpoint can be configured and used with scenes.
This means the enduser is able to trigger a scene (using the frontend, a switch, …)
and the SysAP will inform all configured devices for the scene to switch to a specified state.
For virtual devices the API user can implement this feature using the events received via WebSocket or WebHook.
They contain a scenesTriggered
subobject for each SysAP. In this object you find the information you need
to activate the scene on your virtual device. It is send once per scene activation and only for
virtual devices created by your API user. The contents of these objects are a subset of the devices objects
returned from the configuration
endpoint. It contains only the output datapoints for the channels of the virtual device.
For each output datapoint the value and pairingID
is transmitted.
The following JSON is an example for an event with a non empty scenesTriggered
object.
{
"00000000-0000-0000-0000-000000000000" : {
"configDirty": "false",
"datapoints" : {
"BEED2CD50001/ch0000/idp0004" : "1",
"ABB70000098B/ch0006/idp0005" : "1"
},
"scenesTriggered" : {
"BEED2CD50001" : {
"channels" : {
"ch0000" : {
"outputs" : {
"odp0000" : {"value" : "1", "pairingID" : 256},
"odp0001" : {"value" : "100", "pairingID" : 272}
}
}
}
},
"ABB70000098B" : {
"channels" : {
"ch0006" : {
"outputs" : {
"odp0001" : {"pairingID" : 272, "value" : "100"}
}
}
}
}
},
"scenesTriggered": {},
"devices":{},
"devicesAdded":[],
"devicesRemoved":[],
"timestamp":"2019-09-05T13:54:14.992Z"
}
}
Note: In this example you can also see the input datapoints set to
the scene number (here: 1). These datapoints have a pairingID
of 4 (Scene Control) and
are used internally.
The main difference of triggered scenes and normal datapoint changes is that datapoint changes for your
device always affect only input datapoints. But scenes are configured in the SysAP by
saving the output datapoints for the devices. When the scene is activated the device has to restore the
state to have the same output datapoint values as the scenesTriggered
object specifies.