FIBARO Intercom uses JSON-RPC 2.0 protocol for its API service. See https://www.jsonrpc.org/ for more information about the protocol.
WebSocket client must be used to make calls to Intercom API.
Account
Type: method
Description:
Acquires token used to authenticate other calls of JSON API
Required permissions: none
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
user | string | User’s name | YES | |
pass | string | JSON WEB token or user’s local access password | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
exp_time | string | Expiration time in milliseconds (ms) | YES |
Example
Function logins to Intercom and retrieves token needed for other API calls.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
function WebSocketLogin() { // Check if browser supports WebSocket if ("WebSocket" in window) { // Create new WebSocket client by passing "wss://IntercomIP:8081/wsock" var ws = new WebSocket("wss://192.168.0.19:8081/wsock"); // Assign function to be executed when connection is opened ws.onopen = function() { // Web Socket is connected, send data using send() // Prepare object with data to send var jsonrpc = { "jsonrpc": "2.0", // Method name "method": "com.fibaro.intercom.account.login", // Parameters "params": { // Username for local account // Password for local account "pass": "password" }, "id": "1" }; // Parse data object to string var string_request = JSON.stringify(jsonrpc); // Send the strigified object ws.send(string_request); }; // Assign function to be executed when message is received ws.onmessage = function (evt) { //Extract data from response var received_msg = evt.data; alert("Message is received..." + received_msg); // Parse response data, then save token to some global variable or pass to following API call in different way var json = JSON.parse(received_msg); GLOBAL_TOKEN = json.result.token; }; // Assign function to be executed when connection is closed ws.onclose = function() { // websocket is closed. alert("Connection is closed..."); }; } else { // The browser doesn't support WebSocket alert("WebSocket NOT supported by your Browser!"); } } |
Type: method
Description:
Logs out current user
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: method
Description:
Resets token expiration time
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
exp_time | string | Expiration time in milliseconds (ms) | YES |
Type: method
Description:
Adds new PIN user to the system
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
user | string | User’s name [max length: 64] | YES | |
pass | string | User’s local access password (NOTE: empty – no local access to WSAPI) [max length: 255] | YES | |
pin | string | User’s PIN in ‘4-digit’ format (EXAMPLE: ‘1234’) | YES | |
is_admin | boolean | Administrative privileges option (NOTE: ‘true’ – Admin status will be enabled) | YES | false |
uuid | string | (OPTIONAL) Unique user’s ID [max length: 36] | NO |
Result
Type: integer
Description: ‘0’ – Success
Type: method
Description:
Gets all users (NOTE: Non-admin privileges restrict user to his own account’s management)
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: array of objects
Name | Type | Description | Required | Default value |
---|---|---|---|---|
user | string | User’s name | YES | |
pin | string | User’s PIN in ‘4-digit’ format (EXAMPLE: ‘1234’) | YES | |
is_admin | boolean | User’s administrator privileges (NOTE: ‘true’ – Admin status is enabled) | YES | |
avatar_uri | string | URI to user’s avatar | YES | |
uuid | string | Unique user’s ID | YES | |
confirmed | boolean | Unique user’s ID confirmation status in group | YES |
Type: method
Description:
Removes existing user
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
user | string | Name of user to be removed | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: method
Description:
Changes existing user’s data (NOTE: Non-admin privileges restrict user to his own account’s management. Additionally, current user cannot modify its own ‘admin’ property)
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
user | string | Name of user to be modified [max length: 64] | YES | |
pass | string | (OPTIONAL) New user’s local access password [max length: 255] | NO | |
pin | string | (OPTIONAL) New user’s PIN in ‘4-digit’ format (EXAMPLE: ‘1234’) | NO | |
is_admin | boolean | (OPTIONAL) Administrative privileges option (NOTE: ‘true’ – Admin status will be enabled) | NO | false |
uuid | string | (OPTIONAL) Unique user’s ID [max length: 36] | NO |
Result
Type: integer
Description: ‘0’ – Success
Relay
Type: method
Description:
Gets relay’s state
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
relay | integer | Relay’s ID. [min: 0; max: 1] | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
opened | boolean | State indicator (NOTE: ‘true’ – relay is open) | YES |
Type: method
Description:
Gets default timeout for relay’s open time
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
relay | integer | Relay’s ID. [min: 0; max: 1] | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
timeout | integer | Relay’s ‘open time’ timeout in milliseconds (ms) | YES |
Type: method
Description:
Opens relay instantly
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
relay | integer | Relay’s ID. [min: 0; max: 1] | YES | |
timeout | integer | (OPTIONAL) Relay’s ‘open time’ timeout in milliseconds (ms) [min: 250; max: 30000] | NO |
Result
Type: integer
Description: ‘0’ – Success
Example
Function opens second relay.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
function WebSocketOpenFirstRelay(token) { // Check if browser supports WebSocket if ("WebSocket" in window) { // Create new WebSocket client by passing "wss://IntercomIP:8081/wsock" var ws = new WebSocket("wss://192.168.0.19:8081/wsock"); // Assign function to be executed when connection is opened ws.onopen = function() { // Web Socket is connected, send data using send() // Prepare object with data to send var jsonrpc = { "jsonrpc": "2.0", // Method name "method": "com.fibaro.intercom.relay.open", // Parameters "params": { // Token received as a result of "com.fibaro.intercom.account.login" request "token": token, // ID of relay to be opened "relay": 1 }, "id": "1" }; // Parse data object to string var string_request = JSON.stringify(jsonrpc); // Send the strigified object ws.send(string_request); }; // Assign function to be executed when message is received ws.onmessage = function (evt) { //Extract data from response var received_msg = evt.data; alert("Message is received..." + received_msg); }; // Assign function to be executed when connection is closed ws.onclose = function() { // websocket is closed. alert("Connection is closed..."); }; } else { // The browser doesn't support WebSocket alert("WebSocket NOT supported by your Browser!"); } } |
Type: method
Description:
Sets default timeout for relay’s open time
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
relay | integer | Relay’s ID. [min: 0; max: 1] | YES | |
timeout | integer | New relay’s ‘open time’ timeout in milliseconds (ms) [min: 250; max: 30000] | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: signal
Description:
Signal emitted on relay’s state change
Notify
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
relay | integer | Relay’s ID (NOTE: Available values are [‘0’, ‘1’]) | YES | |
opened | boolean | Relay’s state (NOTE: ‘true’ – Relay is in ‘open’ state) | YES | |
method | string | Method (NOTE: Available values are [‘PIN-ENTERED’, ‘WS_API’, ‘BLE’, ‘DTMF’, ‘NO/NC’, ‘TIMEOUT’]) | YES | |
user | string | User’s name (NOTE: User is determined from PIN value, BLE ID or login depending on the method. For NO/NC and TIMEOUT methods user cannot be determined (thus empty value should be returned). | YES |
Sensors
Type: method
Description:
Sets video options
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
hdr | boolean | HDR usage option (NOTE: ‘true’ – HDR will be enabled) | YES | true |
dewarping | boolean | Dewraping usage option (NOTE: ‘true’ – Dewraping will be enabled) | YES | false |
framerate | integer | Hz, 50 – 50Hz, 60 – 60Hz | YES | 50 |
Result
Type: integer
Description: ‘0’ – Success
Type: signal
Description:
Signal emitted on DayNight sensor’s mode change
Notify
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
mode | string | DayNight mode indicator | YES |
Type: method
Description:
Gets Day/Night mode
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
mode | string | Day/Night mode setting (NOTE: Allowed values are [‘day’, ‘night’, ‘night IR ext’, ‘auto’, ‘auto IR ext’]) | YES |
Type: method
Description:
Sets high threshold (NOTE: Day/Night mode changes to Day when above it)
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
high_threshold | integer | High threshold level in lux (lx) | YES |
Type: method
Description:
Gets low threshold (NOTE: Day/Night mode changes to Night when below it)
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
low_threshold | integer | Low threshold level in lux (lx) | YES |
Type: method
Description:
Gets detected light’s luminosity
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
luminosity | integer | Detected luminosity in lux (lx) | YES |
Type: method
Description:
Sets Day/Night mode
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
mode | string | New Day/Night mode setting (NOTE: Allowed values are [‘day’, ‘night’, ‘night IR ext’, ‘auto’, ‘auto IR ext’]) [min length: 3; max length: 12] | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: method
Description:
Sets high threshold (NOTE: Day/Night mode changes to Day when above it)
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
high_threshold | integer | New high threshold in lux (lx) (EXAMPLE: ’20’) | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: method
Description:
Sets low threshold (NOTE: Day/Night mode changes to Night when below it)
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
low_threshold | integer | New low threshold in lux (lx) (EXAMPLE: ‘4’) | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: method
Description:
Gets sensitiviy of IR Proximity sensor.
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
sensitivity | string | IR Proximity sensor sensitivity. One of values: LOW, MEDIUM, HIGH.) | YES |
Type: method
Description:
Gets timeout for IR proximity sensor
Required permissions: user
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES |
Result
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
timeout | integer | IR Proximity sensor timeout (in milliseconds) | YES |
Type: method
Description:
Sets sensitiviy of IR Proximity sensor
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
sensitivity | string | IR Proximity sensor sensitivity. One of values: LOW, MEDIUM, HIGH. | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: method
Description:
Sets timeout for IR proximity sensor
Required permissions: admin
Parameters
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
token | string | String representation of authentication token | YES | |
timeout | integer | IR Proximity sensor timeout (in milliseconds) | YES |
Result
Type: integer
Description: ‘0’ – Success
Type: signal
Description:
Signal emitted on proximity sensor’s state change
Notify
Type: object
Name | Type | Description | Required | Default value |
---|---|---|---|---|
state | boolean | Proximity sensor’s state (NOTE: ‘true’ – detected object in sensor’s range) | YES |