Attributes
Publish Client-Side Attributes
Section titled “Publish Client-Side Attributes”Upload client-side attributes for one or more devices.
Topic: v1/gateway/attributes
{ "Device A": {"fw_version": "1.0", "battery": 87}, "Device B": {"fw_version": "2.1", "battery": 92}}mosquitto_pub -h "$THINGSBOARD_HOST" -t "v1/gateway/attributes" -u "$ACCESS_TOKEN" -m '{"Device A":{"fw_version":"1.0","battery":87}}'Request Attribute Values
Section titled “Request Attribute Values”Subscribe to the response topic first, then publish the request.
Subscribe: v1/gateway/attributes/response
Publish: v1/gateway/attributes/request
{ "id": 1, "device": "Device A", "client": ["fw_version", "battery"], "shared": ["targetFwVersion"]}| Field | Required | Description |
|---|---|---|
id | Yes | Integer request identifier — echoed in the response |
device | Yes | Device name |
client | No | Client-side attribute keys to return |
shared | No | Shared attribute keys to return |
mosquitto_sub -h "$THINGSBOARD_HOST" -t "v1/gateway/attributes/response" -u "$ACCESS_TOKEN" &mosquitto_pub -h "$THINGSBOARD_HOST" -t "v1/gateway/attributes/request" -u "$ACCESS_TOKEN" -m '{"id":1,"device":"Device A","client":["fw_version"],"shared":["targetFwVersion"]}'Subscribe to Shared Attribute Updates
Section titled “Subscribe to Shared Attribute Updates”Subscribe to receive push notifications when shared attributes change for any downstream device.
Topic: v1/gateway/attributes (subscribe)
mosquitto_sub -h "$THINGSBOARD_HOST" -t "v1/gateway/attributes" -u "$ACCESS_TOKEN"ThingsBoard delivers updates in this format:
{ "device": "Device A", "data": {"targetFwVersion": "2.0", "enabled": true}}