规则节点类型
所有可用的规则节点根据它们的性质进行分组:
- 过滤节点(Filter Nodes)用于消息过滤和路由;
- 丰富节点(Enrichment Nodes)用于更新传入消息的元数据;
- 转换节点(Transformation Nodes )用于更改传入的消息字段,如发起者、类型、有效载荷、元数据;
- 动作节点(Action Nodes )根据传入的消息执行各种动作;
- 外部节点(External Nodes )用于与外部系统交互。
配置
每个规则节点可能具有取决于规则节点实现的特定配置参数。例如,“过滤器 - 脚本”(“Filter - script”)规则节点可通过处理传入数据的自定义 JS 函数进行配置。“外部 - 发送电子邮件”节点配置允许指定邮件服务器连接参数。例如:测试 JavaScript 函数
一些规则节点具有特定的 UI 功能,允许用户测试 JS 功能。单击“测试过滤器函数”后,您将看到 JS 编辑器,该编辑器允许您替换输入参数并验证函数的输出。
定义说明:
- 在左上角的字段中输入消息。
- 左侧消息部分中的消息负载。
- 元数据在右上元数据部分。
- 过滤器部分中的实际JS 脚本。
调试
ThingsBoard 提供查看每个规则节点的传入和传出消息的能力。要启用调试,用户需要确保在主配置窗口中选中“调试模式”复选框。
启用调试后,只要对应的关系类型,用户就可以查看传入和传出的消息信息。有关示例调试消息视图,请参见下图,在以后的文章中也会出现:
预定义的消息类型(重要)
下表列出了预定义的消息类型:
Message Type | Display Name | Description | Message metadata | Message payload |
---|---|---|---|---|
POST_ATTRIBUTES_REQUEST | Post attributes | Request from device to publish client side attributes (see attributes api for reference) | deviceName - originator device name, deviceType - originator device type |
key/value json:{<br /> "currentState": "IDLE"<br />} |
POST_TELEMETRY_REQUEST | Post telemetry | Request from device to publish telemetry (see telemetry upload api for reference) | deviceName - originator device name, deviceType - originator device type, ts - timestamp (milliseconds) |
key/value json:{<br /> "temperature": 22.7<br />} |
TO_SERVER_RPC_REQUEST | RPC Request from Device | RPC request from device (see client side rpc for reference) | deviceName - originator device name, deviceType - originator device type, requestId - RPC request Id provided by client |
json containing method and params:{<br /> "method": "getTime",<br /> "params": { "param1": "val1" }<br />} |
RPC_CALL_FROM_SERVER_TO_DEVICE | RPC Request to Device | RPC request from server to device (see server side rpc api for reference) | requestUUID - internal request id used by sustem to identify reply target, expirationTime - time when request will be expired, oneway - specifies request type: true - without response, false - with response |
json containing method and params: < style=”font-size: 12px;”>{ “method”: “getGpioStatus”, “params”: { “param1”: “val1” } } |
ACTIVITY_EVENT | Activity Event | Event indicating that device becomes active | deviceName - originator device name, deviceType - originator device type |
json containing device activity information:{<br /> "active": true,<br /> "lastConnectTime": 1526979083267,<br /> "lastActivityTime": 1526979083270,<br /> "lastDisconnectTime": 1526978493963,<br /> "lastInactivityAlarmTime": 1526978512339,<br /> "inactivityTimeout": 10000<br />} |
INACTIVITY_EVENT | Inactivity Event | Event indicating that device becomes inactive | deviceName - originator device name, deviceType - originator device type |
json containing device activity information, see Activity Event payload |
CONNECT_EVENT | Connect Event | Event produced when device is connected | deviceName - originator device name, deviceType - originator device type |
json containing device activity information, see Activity Event payload |
DISCONNECT_EVENT | Disconnect Event | Event produced when device is disconnected | deviceName - originator device name, deviceType - originator device type |
json containing device activity information, see Activity Event payload |
ENTITY_CREATED | Entity Created | Event produced when new entity was created in system | userName - name of the user who created the entity, userId - the user Id |
json containing created entity details:{<br /> "id": {<br /> "entityType": "DEVICE",<br /> "id": "efc4b9e0-5d0f-11e8-8559-37a7f8cdca74"<br /> },<br /> "createdTime": 1526918366334,<br /> ...<br /> "name": "my-device",<br /> "type": "temp-sensor"<br />} |
ENTITY_UPDATED | Entity Updated | Event produced when existing entity was updated | userName - name of the user who updated the entity, userId - the user Id |
json containing updated entity details, see Entity Created payload |
ENTITY_DELETED | Entity Deleted | Event produced when existing entity was deleted | userName - name of the user who deleted the entity, userId - the user Id |
json containing deleted entity details, see Entity Created payload |
ENTITY_ASSIGNED | Entity Assigned | Event produced when existing entity was assigned to customer | userName - name of the user who performed assignment operation, userId - the user Id, assignedCustomerName - assigned customer name, assignedCustomerId - Id of assigned customer |
json containing assigned entity details, see Entity Created payload |
ENTITY_UNASSIGNED | Entity Unassigned | Event produced when existing entity was unassigned from customer | userName - name of the user who performed unassignment operation, userId - the user Id, unassignedCustomerName - unassigned customer name, unassignedCustomerId - Id of unassigned customer |
json containing unassigned entity details, see Entity Created payload |
ADDED_TO_ENTITY_GROUP | Added to Group | Event produced when entity was added to Entity Group. This Message Type is specific to ThingsBoard PE. | userName - name of the user who performed assignment operation, userId - the user Id, addedToEntityGroupName - entity group name, addedToEntityGroupId - Id of entity group |
empty json payload |
REMOVED_FROM_ENTITY_GROUP | Removed from Group | Event produced when entity was removed from Entity Group. This Message Type is specific to ThingsBoard PE. | userName - name of the user who performed unassignment operation, userId - the user Id, removedFromEntityGroupName - entity group name, removedFromEntityGroupId - Id of entity group |
empty json payload |
ATTRIBUTES_UPDATED | Attributes Updated | Event produced when entity attributes update was performed | userName - name of the user who performed attributes update, userId - the user Id, scope - updated attributes scope (can be either SERVER_SCOPE or SHARED_SCOPE) |
key/value json with updated attributes:{<br /> "softwareVersion": "1.2.3"<br />} |
ATTRIBUTES_DELETED | Attributes Deleted | Event produced when some of entity attributes were deleted | userName - name of the user who deleted attributes, userId - the user Id, scope - deleted attributes scope (can be either SERVER_SCOPE or SHARED_SCOPE) |
json with attributes field containing list of deleted attributes keys:{<br /> "attributes": ["modelNumber", "serial"]<br />} |
ALARM | Alarm event | Event produced when an alarm was created, updated or deleted | All fields from original Message Metadata isNewAlarm - true if a new alram was just created isExistingAlarm - true if an alarm is existing already isClearedAlarm - true if an alarm was cleared |
json containing created alarm details:{<br /> "tenantId": {<br /> ...<br /> },<br /> "type": "High Temperature Alarm",<br /> "originator": {<br /> ...<br /> },<br /> "severity": "CRITICAL",<br /> "status": "CLEARED_UNACK",<br /> "startTs": 1526985698000,<br /> "endTs": 1526985698000,<br /> "ackTs": 0,<br /> "clearTs": 1526985712000,<br /> "details": {<br /> "temperature": 70,<br /> "ts": 1526985696000<br /> },<br /> "propagate": true,<br /> "id": "33cd8999-5dac-11e8-bbab-ad47060c9431",<br /> "createdTime": 1526985698000,<br /> "name": "High Temperature Alarm"<br />} |
REST_API_REQUEST | REST API Request to Rule Engine | Event produced when user executes REST API call | requestUUID - the unique request id, expirationTime - the expiration time of the request |
json with request payload |