Navbar

Banner dev api light

Introduction

_          _ _
| |__   ___| | | ___
| '_ \ / _ \ | |/ _ \
| | | |  __/ | | (_) |
|_| |_|\___|_|_|\___/     _
__      _____  _ __| | __| |
\ \ /\ / / _ \| '__| |/ _` |
\ V  V / (_) | |  | | (_| |
 \_/\_/ \___/|_|  |_|\__,_|

Welcome to Animus Home Heart API! You can generate an API-key on your Heart to access all the API endpoints locally on the Heart. Same API will be available through cloud but with a different host and authentication later on.

With this API you will be able to get all the devices connected to your Heart. You will be able to read, update and listen for changes using Websocket technology for the devices. The API will be extended with more endpoints as we continue with improvements.

Animus Heart System is based on OSGi Device Abstraction Layer developed by the OSGi Alliance. The REST interface is converted from the internal OSGi service to endpoints.

The following table shows present Animus Heart API versions:

API Version Heart fw Version Documentation
v1-beta 1.3.16 - 1.3.17
v1-beta2 2.0.0 - 2.0.x
v1-beta3 2.1.0 or later v1 docs

Requirements

To use the latest version of the REST API you must be using:

License

You are only allowed to use this API for private use, please read our Terms of Service. If you'd like to use it in commercial purposes please contact us at hi@animushome.com for further information.

Local API access

For local API access replace $host in the endpoints with http://<your-heart-ip>

HTTPS local API

Hearts running FW 2.0 and above also have support for local https. The Heart uses a self-signed certificate (currently it's not possible to upload your own certificate, might be supported in the upcoming versions). Use the following $host for encrypted local communication: https://<your-heart-ip>

Limitations

Resource Limit
REST API 1000 request / day
WebSocket 7000 messages / day

Authentication

To authorize, use this code:

# With shell, you can just pass the correct header with each request
curl "api_endpoint_here"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"

Make sure to replace mysmarthomekey with your API key.

The Heart uses API keys to allow access to the API. You can create an API-key from your Heart. Go to Settings->Developer->Generate API Key.

The Heart expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: Bearer mysmarthomekey

Devices

A device represents a real-life device or a virtual device in the Animus Home system.

Device Attributes

Attribute Type Description
UID string The unique identifier of this device read-only.
types array Array of what kind of device this is. See DeviceTypes list for all available types. Default value is ["device"] read-only.
is_favorite boolean Marks if the device is favorite and should be placed on the dashboard.
security_level integer Tells the security level. See SecurityLevels for all available levels. read-only.
name string The name of the devices.
animus_area string Id of the room that this device is placed. See Areas for more information.
status integer Tells the status of the device Online/Offline etc. See DeviceStatus for all available statuses. read-only.

Device - Type values

Information about what kind of device this is. Note! This doesn't tell which functions the device supports.

Name Meaning
gateway Gateway device, e.g Philips Hue bridge
AC Air Conditioner
tv Television
light_bulb A light bulb
remote_controller A remote controller
button A button, similar to remote controller but fewer buttons
device A generic device
camera A camera device
sensor Some kind of sensor
speaker Speaker for music or other sound
beacon Just a beacon
shades_control Nothing shady, just controller for shades
wall_switch A switch on the wall
heart Animus Heart
fan A fan that spins around
car An automobile
media_streamer Some kind of media streamer
thermostat Thermostat to regulate the temperature
in_wall_outlet An outlet placed in the wall
power_plug A power plug that can be moved easily

Device - Security Level

Security level between the Heart and the device that is connected.

Level Meaning
0 No security -- Device doesn't support a secure way to communicate.
1 Secured -- The communication between the Heart and the device is secure
-1 Security failed -- The device supports secure communication but it was configured to use unsecure communication. E.g. when you include a Z-wave S2 device using no security.

Device - Status

A device can be in different states during it's lifecycle. Here is the list of different states.

Status Code Meaning
1 Removed
2 Offline
3 Online
4 Processing
5 Not initialized
6 Not configured

Get All Devices

Example request:

curl "$host/rest/devices"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"

Example response:

{
  "com.animushome.heart.packages.zwave.devices.010F-9": {
      "properties": {
          "types": [
              "sensor"
          ],
          "is_favorite": false,
          "description": "default zwave product",
          "serial_number": "1001",
          "firmware_version": "0.0.0",
          "hardware_version": "0.0.0",
          "firmware_vendor": "Fibaro System",
          "security_level": 0,
          "security_desc": "The connection uses S0 security, which is considered unsecure",
          "UID": "com.animushome.heart.packages.zwave.devices.010F-9",
          "hardware_vendor": "Fibaro System",
          "DEVICE_CATEGORY": "DAL",
          "name": "fibsensor",
          "model": "1001",
          "animus_area": "area-1-1537883537714",
          "status": 3
      }

  },
  "com.animushome.heart.device.led-1": {
    "properties": {
        "types": [
            "heart"
        ],
        "is_favorite": true,
        "description": "Device to control the Halo on the Animus Heart",
        "serial_number": "01",
        "firmware_version": "0.0.1",
        "hardware_version": "0.0.1",
        "firmware_vendor": "Animus Home",
        "security_level": 1,
        "security_desc": "The connection to Heart Halo is secure",
        "UID": "com.animushome.heart.device.led-1",
        "hardware_vendor": "Animus Home",
        "DEVICE_CATEGORY": "DAL",
        "name": "Heart Halo",
        "model": "com.animushome.heart.device.led-1-model",
        "animus_area": "",
        "status": 3
    }
  }
}

This endpoint retrieves all devices connected to the Heart.

HTTP Request

GET $host/rest/devices

Get a Specific Device

Example request:

curl "$host/rest/devices/com.animushome.heart.device.led-1"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"

Example response:

{
    "properties": {
        "types": [
            "heart"
        ],
        "is_favorite": true,
        "description": "Device to control the Halo on the Animus Heart",
        "serial_number": "01",
        "firmware_version": "0.0.1",
        "hardware_version": "0.0.1",
        "firmware_vendor": "Animus Home",
        "security_level": 1,
        "security_desc": "The connection to Heart Halo is secure",
        "UID": "com.animushome.heart.device.led-1",
        "driver": "com.animushome.heart.device.led-1-driver",
        "hardware_vendor": "Animus Home",
        "DEVICE_CATEGORY": "DAL",
        "name": "Heart Halo",
        "model": "com.animushome.heart.device.led-1-model",
        "animus_area": "",
        "status": 3
    }
}

This endpoint retrieves a specific device.

HTTP Request

GET $host/rest/devices/{id}

URI Parameters

Parameter Type Meaning
id string The UID of the device

Update a Device

Example request:

curl -X PUT "$host/rest/devices/com.animushome.heart.device.led-1"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json" 
  -d '{"name":"My Halo","animus_area":"area-2-1537883537722", "is_favorite": false}'

Example response:

{
    "properties": {
        "types": [
            "heart"
        ],
        "is_favorite": false,
        "description": "Device to control the Halo on the Animus Heart",
        "serial_number": "01",
        "firmware_version": "0.0.1",
        "hardware_version": "0.0.1",
        "firmware_vendor": "Animus Home",
        "security_level": 1,
        "security_desc": "The connection to Heart Halo is secure",
        "UID": "com.animushome.heart.device.led-1",
        "driver": "com.animushome.heart.device.led-1-driver",
        "hardware_vendor": "Animus Home",
        "DEVICE_CATEGORY": "DAL",
        "name": "My Halo",
        "model": "com.animushome.heart.device.led-1-model",
        "animus_area": "area-2-1537883537722",
        "status": 3
    }
}

This endpoint updates a specific device.

HTTP Request

PUT $host/rest/devices/{id}

URI Parameters

Parameter Type Meaning
id string The UID of the device

Only the fields that aren't marked with read-only can be updated, i.e:

Name Type
is_favorite boolean
name string
animus_area string

Functions

A Function contains a specific device functionality like on/off, temperature reporting etc. There are 13 different types of functions that a device can support. All functions are registered in the system as separate services and can be referenced through their UID.

Function Attributes

Example Function:

{
    "serviceProperties": {
        "UID": "com.animushome.heart.device.led-1:switch",
        "device_UID": "com.animushome.heart.device.led-1",
        "property_names": [
            "data"
        ],
        "animus.package.type": "device",
        "type": "light",
        "clazz": "com.animushome.heart.service.dal.functions.BooleanControl",
        "views": [
            "main"
        ],
        "primary": true,
        "group": 1
    },
    "functionProperties": {
        "data": {
            "metadata": {
                "clazz": "com.animushome.heart.service.dal.functions.data.BooleanData",
                "property_access": 7
            },
            "value": {
                "value": true,
                "metadata": { },
                "timestamp": 0
            }
        }
    },
    "functionOperations": { }
}
Attribute Type Description
serviceProperties array Service information array, see serviceProperties for complete information.
functionProperties array Array with key value pairs for each property. See functionProperties for more information.
functionOperations array Array with supported opertations for a function. Note! Invocations on these operations are deprecated and not officially supported by the REST API.

Function - serviceProperties

Attribute Type Description
UID string The unique identifier of this function read-only.
device_UID array The device ID of which this function belongs to read-only.
property_names array Array with the names of the properties found in functionProperties. read-only.
type string The type of this function. A boolean function can be used for both power and light. This function attribute tells which. See FunctionType for all available types. read-only.
clazz string The actual class name of the implementation of this function. See FunctionClass for all available classes. read-only.
views array List of views where the function can be displayed. E.g: ["main", "status", "settings"]read-only.
primary boolean Tells if this function is a primary function and should be treated accordingly. read-only.
group integer Group id for this function. Functions within the same device are grouped based on their group id. read-only.

Function - functionProperties

Attribute Type Description
metadata array Information about the value. The type of FunctionData the value is and the access level of this data. See FunctionData for all available data types. read-only
value FunctionData This is the actual data object that can be updated to e.g. trigger on/off.

Function - Type values

Information about what kind of device this controls. Note! This doesn't tell which functions the device supports.

Name Meaning
light Indicates that it can control light devices
temperature Indicates that it can control temperature devices
flow Indicates that it can control the flow level
pressure Indicates that it can control pressure level
humidity Indicates that it control the humidity level
gas Indicates that it can control the gas level
smoke Indicates that it can control the smoke level
door Indicates that it can control the door position
window Indicates that it can control the window position
liquid Indicates that it can control liquid level
power Indicates that it can control power level
noisiness Indicates that it can control noise level
rain Indicates that it can monitor rain rate
contact Indicates that it can detect contact
fire Indicates that it can detect fire
occupancy Indicates that it can detect presence
water Indicates that it can detect water leak
motion Indicates that it can detect motion
heat Measures thermal energy
cold Measures thermal energy
sound Indicates that it can control sound level

Get all functions for a specific device

Example request:

curl "$host/rest/devices/com.animushome.heart.device.led-1/functions"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"

Example response:

{
    "com.animushome.heart.device.led-1:switch": {
        "serviceProperties": {
            "UID": "com.animushome.heart.device.led-1:switch",
            "device_UID": "com.animushome.heart.device.led-1",
            "property_names": [
                "data"
            ],
            "animus.package.type": "device",
            "type": "light",
            "clazz": "com.animushome.heart.service.dal.functions.BooleanControl",
            "views": [
                "main"
            ],
            "primary": true,
            "group": 1
        },
        "functionProperties": {
            "data": {
                "metadata": {
                    "clazz": "com.animushome.heart.service.dal.functions.data.BooleanData",
                    "property_access": 7
                },
                "value": {
                    "value": true,
                    "metadata": { },
                    "timestamp": 0
                }
            }
        }
    },
    "com.animushome.heart.device.led-1:dim": {
        "serviceProperties": {
            "UID": "com.animushome.heart.device.led-1:dim",
            "device_UID": "com.animushome.heart.device.led-1",
            "property_names": [
                "data"
            ],
            "animus.package.type": "device",
            "type": "light",
            "clazz": "com.animushome.heart.service.dal.functions.MultiLevelControl",
            "views": [
                "main"
            ],
            "primary": false,
            "group": 1
        },
        "functionProperties": {
            "data": {
                "metadata": {
                    "clazz": "com.animushome.heart.service.dal.functions.data.LevelData",
                    "property_access": 7
                },
                "maxValue": {
                    "level": 100,
                    "metadata": { },
                    "timestamp": 0
                },
                "minValue": {
                    "level": 0,
                    "metadata": { },
                    "timestamp": 0
                },
                "step": {
                    "level": 1,
                    "metadata": { },
                    "timestamp": 0
                },
                "value": {
                    "level": 100.0,
                    "metadata": { },
                    "timestamp": 1552653935701
                }
            }
        }
    },
    "com.animushome.heart.device.led-1:color": {
        "serviceProperties": {
            "UID": "com.animushome.heart.device.led-1:color",
            "device_UID": "com.animushome.heart.device.led-1",
            "dal.color.modes": [
                "hs"
            ],
            "property_names": [
                "color"
            ],
            "animus.package.type": "device",
            "type": "light",
            "clazz": "com.animushome.heart.service.dal.functions.ColorControl",
            "views": [
                "main"
            ],
            "primary": false,
            "group": 1
        },
        "functionProperties": {
            "color": {
                "metadata": {
                    "clazz": "com.animushome.heart.service.dal.functions.data.ColorData",
                    "property_access": 3
                },
                "maxValue": {
                    "hue": 1,
                    "saturation": 1,
                    "lightness": 1,
                    "temperature": 0,
                    "metadata": { },
                    "timestamp": 0
                },
                "minValue": {
                    "hue": 0,
                    "saturation": 0,
                    "lightness": 0,
                    "temperature": 0,
                    "metadata": { },
                    "timestamp": 0
                },
                "value": {
                    "hue": 0.6333,
                    "saturation": 1.0,
                    "lightness": 0.5,
                    "temperature": 0,
                    "metadata": { },
                    "timestamp": 1552653935696
                }
            }
        }
    }
}

This endpoint retrieves all functions supported by a specific device

HTTP Request

GET $host/rest/devices/{id}/functions

URI Parameters

Parameter Type Meaning
id string The UID of the device

Get a Specific Function

Example request:

curl "$host/rest/functions/com.animushome.heart.device.led-1:switch"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"

Example response:

{
    "serviceProperties": {
        "UID": "com.animushome.heart.device.led-1:switch",
        "device_UID": "com.animushome.heart.device.led-1",
        "property_names": [
            "data"
        ],
        "animus.package.type": "device",
        "type": "light",
        "clazz": "com.animushome.heart.service.dal.functions.BooleanControl",
        "views": [
            "main"
        ],
        "primary": true,
        "group": 1
    },
    "functionProperties": {
        "data": {
            "metadata": {
                "clazz": "com.animushome.heart.service.dal.functions.data.BooleanData",
                "property_access": 7
            },
            "value": {
                "value": true,
                "metadata": { },
                "timestamp": 0
            }
        }
    }
}

This endpoint retrieves a specific function.

HTTP Request

GET $host/rest/functions/{id}

URI Parameters

Parameter Type Meaning
id string The UID of the function

Get a specific Function Property

Example request:

curl "$host/rest/functions/com.animushome.heart.device.led-1:switch/data"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"

Example response:

{
  "value": false,
  "metadata": {},
  "timestamp": 1553518949702
}

Get a property from a function. This will return a cached value and no asynchronious request will be sent to the node unless you add the parameter no-cache.

HTTP Request

GET $host/rest/functions/{id}/{name}?{no-cache}

URI Parameters

Parameter Type Meaning
id string The UID of the function
name string The property name that you want to update.
no-cache string Set this parameter when you want the server to do an asynchronious call to the node instead of just reading the cache. Note! The actual response will come as an event in the websocket (async call).

Update a Function Property

This endpoint updates a specific function property. Turn the switch on/off, change the color of a light etc.

HTTP Request

PUT $host/rest/functions/{id}/functionProperties/{name}

URI Parameters

Parameter Type Meaning
id string The UID of the function
name string The property name that you want to update.

The Payload should be of FunctionData

Example: Switch off Heart LED

Example request:

curl -X PUT "$host/rest/functions/com.animushome.heart.device.led-1:switch/functionProperties/data"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"
  -d '{"value":false}'

Example response:

{
  "value": false,
  "metadata": {},
  "timestamp": 1553518949702
}

PUT $host/rest/functions/com.animushome.heart.device.led-1:switch/functionProperties/data

This is an example of how to turn off the Heart LED Ring (Halo). You need to send a BooleanData object in the request.

Example: Change Heart LED Color

Example request:

curl -X PUT "$host/rest/functions/com.animushome.heart.device.led-1:color/functionProperties/color"
  -H "Authorization: Bearer mysmarthomekey" -H "Content-Type: application/json"
  -d '{"hue":0.325, "saturation": 1, "lightness": 0.5}'

Example response:

{
  "hue": 0.325,
  "saturation": 1.0,
  "lightness": 0.5,
  "temperature": 0,
  "metadata": {},
  "timestamp": 1553518539356
}

This is an example of how to change the color of the Heart LED Ring (Halo). You need to send a ColorData object in the request.

PUT $host/rest/functions/com.animushome.heart.device.led-1:color/functionProperties/color

FunctionClass

There are 13 predefined class types for each function. Each class have predefined properties and methods. However you could derive that from the data object itself and there is no actual need to follow the clazz type. OSGi provides this modular way of describing functions from the data object itself, however we provide this as extended information.

Alarm

Property Type Meaning
alarm AlarmData Property for the alarm data object.

BooleanControl

Property Type Meaning
data BooleanData Property for the boolean data object.

BooleanSensor

Property Type Meaning
data BooleanData Property for the boolean data object.

Camera

Property Type Meaning
feed CameraData Property for the feed data object.

ColorControl

Property Type Meaning
color ColorData Property for the color data object.

Keypad

Property Type Meaning
key KeypadData Property for the key data object.

MediaControl

Property Type Meaning
state MediaData Property for the media data object.

Meter

Property Type Meaning
current LevelData Property for the current data object.
total LevelData Property for the total data object.

MultiLevelControl

Property Type Meaning
data LevelData Property for the level data object.

MultiLevelSensor

Property Type Meaning
data LevelData Property for the level data object.

StringControl

Property Type Meaning
data StringData Property for the string data object.

WakeUp

Property Type Meaning
awake BooleanData Property for the awake data object.
wakeUpInterval LevelData Property for the wake up interval data object.

Events

Animus Home uses websocket technology to post eventable properties when they occur.

Websocket Authentication

Authentication to websocket is done by setting the Sec-Websocket-Protocol header and then sending a message to the server containing your api key.

  1. Set the Header Sec-Websocket-Protocol: AHauth

  2. Connect to the websocket ws://$host

  3. Send the authorization message within 2 seconds Authorization: Bearer mysmarthomekey

  4. Receive a successful response authenticated

Function Events

Example JavaScript ws connection:


var wsUri = "ws://$host/heart/events";
var protocol = "AHauth";
var websocket = new WebSocket(wsUri, protocol);

websocket.onopen = function(evt) {
  console.debug("ws open", evt);
  //First message after connection open must be the Authorization message
  //Send Authorization message within 2 seconds, otherwise socket will get closed
  websocket.send("Authorization: Bearer mysmarthomekey");
};
websocket.onclose = function(evt) {
  console.debug("ws close", evt);
};
websocket.onerror = function(evt) {
  console.error("ws error", evt);
};

//All events will be received by this callback function
websocket.onmessage = function(evt) {
  console.log(evt.data)
};

Example on received data message


{
  "functionUID": "com.animushome.heart.device.led-1:switch",
  "property": "data",
  "topic": "org/osgi/service/dal/FunctionEvent/PROPERTY_CHANGED",
  "value": {
    "metadata": {},
    "timestamp": 1553546983043,
    "value": true
  }
}

A connection on this websocket will provide with function messages from the server.

WebSocket connection

GET ws://$host/heart/events?tx-status=<true|false>

URI Parameters

Parameter Type Meaning
tx-status Boolean This parameter tells the server that you want to have transmission information from the underlying protocols, e.g Z-wave, 433Mhz etc, on the websocket during a request. If the parameter is omitted it will be set to true.

Websocket messages

Property changed

When a property of a function is changed, e.g. a light is turned on, an event with the following object is sent on the websocket with the topic org/osgi/service/dal/FunctionEvent/PROPERTY_CHANGED

Name Description
topic The topic of the received event.
functionUID The UID of the function.
property The property name in the function.
value The new property value.

TX information

When an underlying protocol (Z-wave) sends transmission information for a request made by a device it will have the following object with the topic org/osgi/service/dal/FunctionEvent/TX_STATUS.

Name Description
topic The topic of the received event.
functionUID The UID of the function.
property The property name in the function.
txData The TX information as object with seq and status [ACK, NACK, NACK_WAITING]

FunctionData

Properties in a function can be of these types.

AlarmData

Fields Type Meaning
type Integer Type of Alarm, see the complete list here AlarmTypes.
event Integer The event that triggered the Alarm, see the complete list here AlarmEvents
description String A short description of the cause. Eg. Smoke Detected
detail String Detailed description of the alarm and perhaps information about what action to take.
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

AlarmTypes

Type that alarm can have

Type Meaning
0 Undefined
1 Access Control
2 Burglar
3 Cold
4 Gas CO
5 Gas CO2
6 Heat
7 Hardware fail
8 Power fail
9 Smoke
10 Software fail
11 Tamper
12 Water

AlarmEvents

Events that can trigger alarms

Event Meaning
0 Inactive
1 Maintenance
2 Silenced
3 Test
4 Active
5 Unknown

BooleanData

Fields Type Meaning
value Boolean True or false
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

CameraData

Fields Type Meaning
url String URL path to the camera stream
snapshot String path to the latest snapshot taken
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

ColorData

Fields Type Meaning
hue Double The hue value between 0-1
saturation Double The saturation value between 0-1
lightness Double The lightness value between 0-1
temperature Double Temperature in Kelvin
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

KeypadData

Fields Type Meaning
type Integer Type of the key action, see available types KeypadTypes
subType Integer Sub type of the key action, see available sub types KeypadSubTypes
keyCode Integer Id of the key
keyName String Name of the key
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

KeypadTypes

Type of key action

Event Meaning
0 Pressed
1 Released

KeypadSubTypes

Sub type of the key action

Event Meaning
1 Pressed
2 Long pressed
3 Double pressed
4 Double long pressed

LevelData

Fields Type Meaning
level Double Value of the level
unit String SI unit of the level
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

MediaData

Fields Type Meaning
mediastate String The state of the media player, see complete list for available MediaStates
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

MediaStates

Possible states of a media player

Event Meaning
playing Media player is playing
paused Media player is paused
stopped Media player is stopped

StringData

Fields Type Meaning
value String A string value
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated

VolumeData

Fields Type Meaning
level Double The volume level
muted Boolean Boolean to tell if the volume is muted or not
metadata Map Extra information about the data object
timestamp Long A timestamp when this data was updated