Resource Types

type

Introduction

Resource type provides 2 features for all resources that are associated to the resource type:

  • define “default” metadata (including the metrics interface which is linked to the sensory information and command interface which allows you to abstract actual actuators implementations)
  • define a standard set of tasks that need to be executed

With most of the IoT platforms, you would find a ResourceType to be called a “template”, since they refer to this sort of modeling as a way to model different device categories using the same JSON template. In our case, we use a template in the rules context. More importantly, our abstraction allows to model both “object templating” together with rules associations, as described further.

Default Metadata

Provisioning API allows you to associate metadata with resource. Resources are either discovered by Waylay (as soon as data is pushed towards Waylay Broker) or you can as well create them using REST call. Next to the resource CRUD related calls, waylay also allows you to create ResourceType entities, and let you link resource to a type using metadata (please see example below). As soon as a resource is linked to the resource type, all metadata values of that type are inherited for that resource. Resource can still overwrite any specific attribute in its metadata model.

Default Tasks

You can also associate templates with resource type. This will automatically create tasks (one for each template) for each resource that get’s associated with the resource type. If the resource gets disassociated from the resource type, any of those tasks is automatically deleted. If a template is added to a resource type, a task will be started for that template for every resource currently associated to the resource type and likewise, tasks for a template that is removed from the resource type will be deleted for every resource associated to the resource type Tasks that are automatically created via resource type can be seen in the task overview as Managed tasks.

Here is an example of resource types:

types

Resource type configuration

In this example, we selected Sigfox type (Nucleo) and created few attributes (we could do the same over REST)

types

Here also added one template to this resource type:

template

Now, let’s go to the resource view, where we select one resource that belongs to this type. We see the complete metamodel for that resource. Some of the properties are inherited from the resource type.

metamodel

Here is the Provisioning task, which was executed only once as soon as the resource was associated with the resource type

task