Repository

IoT server

Fusio is a proof-of-concept server built for managing IoT data and acting on it. One of the main ideas is to be able to gather devices and measurements as groups and aggregate data based on groups rather than on devices. Periodic alarms can be checked upon this data and notify (webhooks at the moment) user / service about it.

Features

  • Rest Api:
    • Users management
    • Groups management
    • Devices management
    • Measurements aggregations
    • Triggers/alarms with webhooks, e.g. “mean(temperature) > 10” => send message

Technologies used:

  • Relational database (Postgres)
  • Time-series database (Influxdb v1)

Simplified API description

Overview on getting started:

  1. Create groups (e.g. garage, house, office)
  2. Create devices and get api keys for them
  3. Assign devices to groups. Groups and devices have many-to-many relation.
  4. Configure devices to upload their data via measurements-endpoint.
  5. Configure alarms (e.g. if garage mean temperature < 10, fire webhook)

Auth: POST /api/v1/auth/login

Devices

Device represents single device.

  • List devices: GET /api/v1/devices

Sample output:

[
    {
        "id": "752a864e-878c-4cc1-b0f2-7ccb353f9482",
        "name": "temperature sensor 1",
        "info": "misc info",
        "type": "sensor"
    },
    {
        "id": "ce970e2b-81bb-4134-ad78-a4b05cd7de85",
        "name": "humidity sensor 1",
        "info": "Demo device",
        "type": "sensor"
    },
]
  • Get device: GET /api/v1/devices/{id}
  • Create device: POST /api/v1/devices:
{
    "name": "test",
    "info": "Display devices",
    "type": "controller"
}

which returns:

{
    "api_key": "vuQM9HF4swkvCLFkx9a1",
    "id": "795552b2-bb04-49d4-b01b-83fbc42275fd"
}

Groups

Group is a many-to-many collection of devices. Measurements can be queried and alarms evaluated on groups rather than individual devices. Device data is available too, naturally.

  • List: GET /api/v1/groups
[
    {
        "id": "7c95da67-eb64-4c7b-b22a-bcdca1ebf505",
        "name": "TestGroup1",
        "info": "Garage sensors",
        "devices": [
            "ce970e2b-81bb-4134-ad78-a4b05cd7de85",
            "7147a8bc-66c6-43bc-8f87-c609d7721ec0",
            "6421bd08-548d-4c8e-a822-1e38944238ee"
        ]
    }
]
  • Create: POST /api/v1/groups (name,info)

  • Add devices to group: POST /api/v1/groups/{groups}, body: {“ids”: […]}

  • Get measurements for group: GET /api/v1/groups/{id}/measurements, returns all known measurements for given group:

{
    "Measurements": [
        "decibels",
        "power",
        "temperature"
    ]
}
  • Search groups: GET /api/v1/groups/search

Measurements

Measurements are numerical data that devices measure and save. Measurements can be queried per-device or per-group.

  • Insert measurement: POST /api/v1/measurements
  • Get measurements: GET /api/v1/measurements

Alarms

Alarms are pre-configured triggers for incoming data, which can fire events. Currently supported is Webhook. Trigger can contain aggeregations (min, max, deviation) and evaluate all measurements from device group.

  • All alarm: POST /api/v1/alarms
{
    "name": "temperature warning",
    "info": "Warning",
    "message": "temperature is too high",
    "enabled": true,
    "group": "{group-id}",
    "past": "15m",
    "filter": "mean(temperature) > 23 && mean(humidity) > 45 ",
    "interval": "180s",
    "trigger": 5
}

With this configuration, ’temperature’ and ‘humidity’ measurements are evaluated for given group. If mean of either exceeds limit for past 15 minutes, an event is fired. This rule is evaluated every 3 minutes.

Alarm output channel configuration