ThingSpeak Resource

Last modified 22 Apr 2021 17:31 +02:00

We need to create channels within a ThingSpeak user account. There is a nice REST API for this so we decided to implement the ThingSpeak connector using existing ScriptedREST connector.

Channel Attributes

The connector manages one type of objects: channels. These are defined as having object class of ri:channel. Recommended mapping for them is kind=generic, intent=channel. Channel objects have the following attributes:

Attribute Description Comment

name

The name of the channel

Required, but only because of ConnId architecture (ThingSpeak does not require a channel to have a name).

description

The description of the channel

field1..8

Names of fields 1 - 8

Write only (cannot be retrieved back from ThingSpeak); in this story we use only the first field to show the temperature.

readKey

A key to read from the channel.

Read only (generated by ThingSpeak, unable to modify it from midPoint)

writeKey

A key to submit data to the channel.

Read only (generated by ThingSpeak, unable to modify it from midPoint)

In the future we might support other attributes like latitude, longitude, elevation, metadata, tags, URL, public/private field, more than one read key, as well as re-generating new keys on demand. (The slight problem is that some of these attributes - namely, URL and public/private field - cannot be retrieved back from ThingSpeak; but we’ll cope with that somehow.)

Configuring the resource

Resource provides a set of configuration properties, mostly needed for ScriptedREST connector. For example, script file names (for create, update, delete, search and similar operations). These are not to be changed when deploying the connector. We need to configure only one:

Property Value

password

user’s API key

(You might ask what about the login. The answer is that ThingSpeak does not use login when authenticating access. Since the ScriptedREST connector requires the presence of login property, it can be set to any non-empty value and is ignored.)