Matter: Clusters, Attributes, Commands | by Kedar Sovani | Dec, 2021

Espressif Matter Series #2

[This is article #2 in the Espressif Matter Series of articles. You may read the first part here.]

In the previous article we looked at what does Matter mean to you. Today, let’s talk about an important part of Matter, its data model. The data model of Matter defines the typical elements that go into making of a typical Matter node. As a device developer, you would typically express the capabilities of your device through this data model.

Simplistic Data Model Tree

For better understanding, let’s consider we are building a luminaire that has 2 lights: one dimmable, one simple on/off.

The following diagram shows a simplistic view of how this can be represented in the Matter’s data model.

Simplistic Representation of a Matter Data Model

Node: In our case, the luminaire is a node. This is a uniquely network addressable entity that exposes some functionality. This is typically a physical device that a user can recognise as a whole device.

Endpoint: Each node has a number of endpoints. An endpoint could be thought of like a virtual device that provides services that could be logically grouped together. In our example above, our luminaire has 2 separate lights, one dimmable, one on-off. Each of these will have an endpoint of their own.

Notice that endpoint 0 is reserved. This contains certain services that are applicable to the entire node. We will look at what this contains later in the section.

The Matter specification defines certain common Device Types. For example, the On/Off Light and Dimmable Light, that you see within endpoints 1 and 2 are standard device-types defined by Matter. A device type is used to indicate a set of commonly available functionality.

Clusters: A cluster groups together commonly used functionality in a reusable building block.

In our diagram, our first light (endpoint 1), is shown with 2 standard clusters, On/Off cluster, and Level Control cluster. The On/Off cluster provides a service to switch on or off certain things. The Level Control cluster provides a service that enables configuring levels of certain things. In our case, the On/Off cluster helps switch on or off the light and the Level Control cluster helps configure the brightness of our light.

If our light had supported controlling the colour, it would have another standard cluster called the Color Control cluster.

Our second light (endpoint 2), is just an on/off light, hence it only includes the On/Off cluster.

As you may notice from the diagram, clusters contain attributes and commands.

Attributes: Attributes indicate something that can be read or written to. In our example, the OnOff cluster has an OnOff attribute that maps to the actual state of the device. Similarly, in the Level Control cluster there is a Current Level attribute that maps to the current level that is set.

Attributes may be persistent or volatile (lost across reboots), and also read-only or read-write.

The Matter specification includes a list of data types that may be possible for attributes. These include the typical, boolean, integers (signed/unsigned), floats, enumerations, strings, or even collections (lists or structures).

Commands: A cluster command provides an ability to invoke a specific behaviour on the cluster. A command may have parameters that are associated with it. In our diagram above, the On/Off cluster has a Toggle command that toggles the current On/Off attribute of the cluster. The Level Control cluster has commands like MoveToLevel, Move, Step, that move the current level of the cluster in specified ways.

These are the typical elements of the Matter data model. The Matter specification provides a list of standard clusters and their attributes and commands. You may peruse this to check how it aligns with the capabilities of your device.

Now that we’ve looked at the common elements in Matter’s data model, let’s understand another concept Cluster servers and clients.

Every Matter cluster has a Cluster Server, and a Cluster Client counterpart. In the diagram above, our device included Cluster Servers, as they provide the service. Interaction with these is done through Cluster Clients.

The following diagram demonstrates this well:

  • Here a Matter Dimmer Switch implements OnOff and Level Control Cluster clients. These clients talk to the corresponding servers on the light, to control them.
  • We also have a Matter Simple Switch, that only implements an OnOff Cluster client.
  • Finally, a phone app that controls the same Light will also implement the relevant cluster clients to control the light.
  • Note here that the Dimmer Switch, Simple Switch, Light as well as the phone-app, are all Matter nodes.

Let’s look at some other examples that drive the point home.

Source link

%d bloggers like this: