v3.20.0

Getting Started Devices Gateways Integrations Reference
Get The Things Stack

Integrations

    Overview
  • Adding Applications
  • Adding Integrations
  • Cloud Integrations
    • akenza
    • AllThingsTalk Maker
    • AnyViz
    • AWS IoT
    • Azure IoT Central
    • Azure IoT Hub
    • Blockbax
    • Cayenne
    • Cloud Studio
    • Daizy
    • Datacake
    • deZem
    • Homey
    • InfluxDB Cloud 2.0
    • IoT in a Box
    • Kaa
    • MClimate
    • my IoT open Tech
    • Qubitro
    • TagoIO
    • Telemetry2U
    • Tellsens
    • thethings.iO
    • ThingsBoard
    • ThingSpeak
    • TTN Mapper
    • Ubidots
    • UIB
    • Widgelix
    • Withthegrid
  • MQTT Server
  • Pub/Sub
  • LoRa Cloud
  • Node-RED
  • IFTTT
  • Payload Formatters
  • Storage Integration
  • Webhooks

Blockbax

Blockbax is a fully configurable and scalable cloud IoT platform which requires no programming.

The most important concept in the Blockbax Platform is a subject. Typically this is the business object you want to monitor such as a building, but it can be a device in its own right as well. You can also relate subjects together, for example to create composite structure like a building with floors. A subject can have metrics which are the things being measured. Besides a subject can also have properties to provide extra information (metadata) about the subject. These can be used throughout the platform for filtering, creating slices, drilldowns and aggregations. In order to enforce structure and make it easy to scale there are subject types which are the templates / blueprints of your subjects.

Check the Blockbax documentation page for more info and the short video below for an impression.

Subject composition

Prerequisites

  1. Own a Blockbax project or request one if you do not have an account yet.

Blockbax Setup

Login to the Blockbax Platform.

Create a subject type and configure metrics. External IDs for these metrics need to match the property names returned by the uplink payload formatter that will be configured on The Things Stack.

Relating Blockbax metrics to the Things Stack

Configure The Things Stack

Make sure your device is added to The Things Stack. See Adding Devices for more info. Many Device Repository payload formatters output payloads such that it can be directly ingested by the Blockbax Platform. If this is not the case, then please follow the instruction below to create a custom payload formatter.

Create payload formatter

On the left menu of your The Things Stack application, select Payload formatters → Uplink.

Select Javascript payload formatter type.

Paste the following contents in the Formatter parameter window:

function decodeUplink(input) {
    decoded = decoder(input.bytes)
    return {
        data: {
            // For numeric metrics
            <Blockbax-external-metric-ID>: decoded.exampleNumber,

            // For text metrics
            <Blockbax-external-metric-ID>: decoded.exampleText,

            // For location metrics
            <Blockbax-external-metric-ID>: {
                lat: decoded.exampleLatitude,
                lon: decoded.exampleLongitude
            }
        }
    };
}

function decoder(bytes) {
    // Add the logic that decodes the bytes from your device.
    return decodedBytes
}

The functions presented above need to be modified against your setup. See example below.

Uplink payload formatter example
    function decodeUplink(input) {
      decoded = decoder(input.bytes)
      return {
        data: {
          battery: decoded.battery,
          temperature: decoded.temperature,
          humidity: decoded.humidity,
          door: decoded.door
        }
      };
    }

    function decoder(bytes) {
        var decoded = {};

        for (var i = 0; i < bytes.length;) {
            var channel_id = bytes[i++];
            var channel_type = bytes[i++];
            // BATTERY
            if (channel_id === 0x01 && channel_type === 0x75) {
                decoded.battery = bytes[i];
                i += 1;
            }
            // TEMPERATURE
            else if (channel_id === 0x03 && channel_type === 0x67) {
                // ℃
                decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10;
                i += 2;

                // ℉
                // decoded.temperature = readInt16LE(bytes.slice(i, i + 2)) / 10 * 1.8 + 32;
                // i +=2;
            }
            // HUMIDITY
            else if (channel_id === 0x04 && channel_type === 0x68) {
                decoded.humidity = bytes[i] / 2;
                i += 1;
            }
            // DOOR
            else if (channel_id === 0x06 && channel_type === 0x00) {
                decoded.door = (bytes[i] === 0) ?  0 :  1;
                i += 1;
            } else {
                break;
            }
        }

        return decoded;
    }

    function readUInt16LE(bytes) {
        var value = (bytes[1] << 8) + bytes[0];
        return value & 0xffff;
    }

    function readInt16LE(bytes) {
        var ref = readUInt16LE(bytes);
        return ref > 0x7fff ? ref - 0x10000 : ref;
    }

When done, click Save changes.

Setting up the payload formatter

Create webhook

Use the Blockbax Webhook template to create a Webhook integration on The Things Stack. Select Integrations → Webhooks on the left hand menu. Click Add webhook and select the Blockbax tile.

Setting up the webhook

Enter an arbitrary Webhook ID, enter your Project ID and Access token. The project ID is contained in your project’s URL, e.g. if the project URL is app.blockbax.com/projects/40edc099-7a41-4af3-9fa4-2fa4bc23a87a/, the project ID is 40edc099-7a41-4af3-9fa4-2fa4bc23a87a.

Additionally, you can choose to create subjects manually with external IDs matching the device IDs. In that case set the Automatically create subjects? option to false. The default true will create a subject automatically if a subject does not exist and if the property names returned by the uplink payload formatter match the external IDs for these metrics in the Blockbax platform (see above).

To see the values of all parameters of the Blockbax integration, click on the integration after you created it with the Webhook template.

Once you have added the integration, check your Blockbax project to see the measurements coming in!

← Uninstall Cayenne →

On this page

  • Prerequisites
  • Blockbax Setup
  • Configure The Things Stack

The Things Stack

Getting Started

Devices

Gateways

Integrations

Reference

Contributing

GitHub

Forum

About Us

The Things Network

The Things Industries

About this page

Last changed by Blockbax on 02 Feb 2022.
doc: Update Blockbax integration docs (#753)

Edit on Github