Contents

AWS IoT Thing Attributes - introduction

Overview

The IoT Thing is a virtual representation of a physical device or logical entity (for instance: an application).

Following Thing properties describe an IoT Thing:

  • Thing Name
  • Thing Type
  • Thing Attributes
  • Thing Groups
  • Billing Group

AWS IoT Thing properties
AWS IoT Thing properties

Thing Attributes

Thing Attributes are key-value pairs that record information about the Thing (for instance: the hardware version or vendor).

We can create an IoT Thing and define Thing Attributes using the AWS SDK for Python (Boto3).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import boto3
import json

# A session manages state about a particular configuration.
# I recommend you specify profile and region - that is a good development practice.
session = boto3.Session(profile_name='train',region_name='eu-west-1')

# Obtain the IoT Client.
iot_c = session.client('iot')

# Create an AWS IoT Thing and device Thing Attributes.
iot_c.create_thing(
    thingName="TestThing001",
    attributePayload={
        'attributes': {           # max three attributes; valid types: <class 'str'>
            'fw_version': "0.1",
            'hw_version': "2",
            'vendor': "abc"
        }
    }
)

# List IoT Things managed by the AWS Thing Registry in a region defined by Session.
r = iot_c.list_things()

print(json.dumps(r['things'],indent=2))

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[
  {
    "thingName": "TestThing001",
    "thingArn": "arn:aws:iot:eu-west-1:693854281758:thing/TestThing001",
    "attributes": {
      "fw_version": "0.1",
      "hw_version": "2",
      "vendor": "abc"
    },
    "version": 1
  }
]

AWS Thing Registry view in the AWS Console:

AWS IoT Thing
AWS IoT Thing

💡Note:

  • Things without a specified Thing Type can have up to 3 attributes.
  • Things with a specified Thing Type can have up to 50 attributes.

I cover the Thing Type in my next post.

Boto3 Session - [link]
Boto3 IoT Client - [link]
AWS IoT Thing Registry - [link]
Named profiles for the AWS CLI - [link]

Video

Support quality content❤️ Donate💰

Sign up for news: (by subscribing you accept the privacy policy)