设备属性

属性是附加到事物的键/值事实 - firmware_version、polling_interval_seconds、fleet_tier 等。每个属性都位于三个存储桶之一中,这三个存储桶的不同之处在于谁可以写入它以及它是否同步到设备。作为设备集成商,您需要与这三者中的两个合作。

三个桶

类别

谁写的

设备同步

按键示例

CLIENT

仅设备

设备报告;云读

firmware_version、mac_address、boot_count、hardware_revision

SHARED

云和设备

两个方向

polling_interval_seconds、telemetry_sample_rate、enabled_features

SERVER

仅云

从未发送到设备

仅限租户方组织

您的设备固件涉及客户端(它报告的事实)和共享(它接收并确认的配置)。 SERVER 存储桶是云端组织,永远不会到达设备 - 您可以忽略它。

键由您定义。密钥必须匹配^[a-zA-Z_][a-zA-Z0-9_]{0,62}$;值可以是字符串、数字、布尔值、小对象或数组。

客户 — 报告事实

设备是 CLIENT 属性的真实来源。它会在连接时以及更改时报告它们;云可以读取它们,但永远不会写入它们。客户端报告利用设备现有的报告状态通道 - 无需构建单独的有线消息。

如果同一密钥的两个报告未按顺序到达,平台将保留具有较晚设备时间戳的报告(最后写入者按设备时间获胜),因此延迟或重播的报告永远不会覆盖较新的值。

共享 — 接收配置,确认它

SHARED属性是双方都关心的配置。云为设备推送新的价值;设备影响它并确认它。平台将确认的值记录为设备当前的有效设置。

如果云写入 SHARED 值时设备处于离线状态,写入操作将被排队并在设备的下一次连接上传递 - 您不会丢失设备睡眠时所做的配置更改。

连线主题

CLIENT 和 SHARED 在您的设备自己的子树上使用以下主题(请参阅设备 MQTT 主题访问):

主题

方向

承载内容

device/{thing_id}/attribute/client

设备 → 云

报告的客户端属性(报告状态线)

device/{thing_id}/attribute/shared/push

云 → 设备

共享值生效

device/{thing_id}/attribute/shared/ack

设备 → 云

确认影响值

冻结电汇消息(DeviceAttributeSharedPush、DeviceAttributeSharedAck)在DDI-1合约中定义。使用下面的 SDK,而不是手动编码。

Python SDK

设备端DDI SDK(SiriusVoyager/ddi,Python)为您处理两个方向。构造一个客户端,注册一个 SHARED 回调,并报告 CLIENT 属性:

from fgai_mqtt import FGAIDeviceClient, DeviceConfig

client = FGAIDeviceClient(DeviceConfig(device_id="my-thing-id", ...))

# Receive SHARED-bucket pushes from the cloud. The SDK effects the value into a
# local shadow and publishes the ack for you — your callback just applies it.
def apply_shared(key, value):
    print(f"cloud set {key} = {value}")

client.set_shared_attribute_callback(apply_shared)
client.connect()

# Report CLIENT-bucket facts up to the cloud.
client.report_client_attribute({"firmware_version": "8.4.2", "boot_count": 12})

# The last SHARED values the device received + effected:
print(client.shared_attribute_shadow)

调用

类别

它的作用

report_client_attribute(attributes, version=None)

CLIENT

报告设备拥有的事实

set_shared_attribute_callback(fn)

SHARED

注册fn(key, value),在SDK自动确认之前调用以实现每次云推送

shared_attribute_shadow

SHARED

设备最后生效的共享值(key → value)

SDK 始终在您的回调运行后发布共享确认,因此云的有效值记录与设备保持同步 - 即使您的回调引发。

Did my change reach the device?

A cloud write to the SHARED bucket is sent over the device's live session, or queued for its next connection. The /attribute-pushes/v1/things/{thing_id} capability reports the dispatch status of those writes — per attribute key, what the platform did with each request:

state

它的作用

pending_session

the device was offline; the request is queued and will be sent on its next connection (retry_pending: true)

pushed

the request was published on a live device session

failed

the request was abandoned — the retry budget was spent, or it aged out of the queue — and will not be retried

fgai attribute-pushes things-get --thing <thing-id>            # newest first, every attribute key

Reading this surface requires a grant. The caller's principal must hold ThingIoAttributePushReadAccess (attach it to a service principal with fgai identity policy attach --account <id> --policy <policy-id>). A caller without it is refused with a policy error whose body names the missing action (thingio:AttributePush:Read) — read the action field rather than assuming a generic denial. Error bodies are converging to RFC 7807 application/problem+json across Thing* services (PLT-0095); consult the response body, not just the status code.

What this surface is not:

  • pushed does not mean applied. It means the platform published the down-channel message to a live session — not that the device received it, and not that the device applied it. Nothing here claims a configuration is in effect on a device.

  • It never reports a device acknowledgement. The device's SHARED-bucket ACK (see the SDK's auto-ack above) is recorded in the attribute audit — GET /attributes/v1/things/{thing_id}/audit shows the wire change whose source is the device. An acknowledgement is evidence the device received the value, which is still not the same claim as "applied".

  • SERVER-bucket values have no dispatch status at all — they never touch a device.

The attribute audit is not the platform audit chain. GET /attributes/v1/things/{thing_id}/audit reads the attribute-change audit (attribute_audit); business events such as enrollment are in the audit chain and do not appear here. A tenant read of the chain by target FRN is tracked in trustmint#525.

Each row carries the attribute key, the version the request was made at, attempts (delivery attempts spent), superseded (a later request exists for the same key — the device drains in order, so the newer request wins), retry_pending, and created_at / updated_at timestamps. Attribute values are not repeated here; read those through the attribute API, where your normal permissions apply.