5 changed files with 1604 additions and 4 deletions
File diff suppressed because it is too large
@ -0,0 +1,146 @@ |
|||
{ |
|||
"ruleChain": { |
|||
"additionalInfo": null, |
|||
"name": "Root Rule Chain", |
|||
"firstRuleNodeId": null, |
|||
"root": false, |
|||
"debugMode": false, |
|||
"configuration": null |
|||
}, |
|||
"metadata": { |
|||
"firstNodeIndex": 2, |
|||
"nodes": [ |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 824, |
|||
"layoutY": 156 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode", |
|||
"name": "Save Timeseries", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"defaultTTL": 0 |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 825, |
|||
"layoutY": 52 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.telemetry.TbMsgAttributesNode", |
|||
"name": "Save Client Attributes", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"scope": "CLIENT_SCOPE" |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 347, |
|||
"layoutY": 149 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.filter.TbMsgTypeSwitchNode", |
|||
"name": "Message Type Switch", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"version": 0 |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 825, |
|||
"layoutY": 266 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.action.TbLogNode", |
|||
"name": "Log RPC from Device", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);" |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 825, |
|||
"layoutY": 379 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.action.TbLogNode", |
|||
"name": "Log Other", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"jsScript": "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);" |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 825, |
|||
"layoutY": 468 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.rpc.TbSendRPCRequestNode", |
|||
"name": "RPC Call Request", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"timeoutInSeconds": 60 |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 1069, |
|||
"layoutY": 90 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.filter.TbJsFilterNode", |
|||
"name": "Is Thermostat?", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"jsScript": "return metadata[\"deviceType\"] === \"thermostat\";" |
|||
} |
|||
} |
|||
], |
|||
"connections": [ |
|||
{ |
|||
"fromIndex": 0, |
|||
"toIndex": 6, |
|||
"type": "Success" |
|||
}, |
|||
{ |
|||
"fromIndex": 2, |
|||
"toIndex": 4, |
|||
"type": "Other" |
|||
}, |
|||
{ |
|||
"fromIndex": 2, |
|||
"toIndex": 1, |
|||
"type": "Post attributes" |
|||
}, |
|||
{ |
|||
"fromIndex": 2, |
|||
"toIndex": 0, |
|||
"type": "Post telemetry" |
|||
}, |
|||
{ |
|||
"fromIndex": 2, |
|||
"toIndex": 3, |
|||
"type": "RPC Request from Device" |
|||
}, |
|||
{ |
|||
"fromIndex": 2, |
|||
"toIndex": 5, |
|||
"type": "RPC Request to Device" |
|||
} |
|||
], |
|||
"ruleChainConnections": [ |
|||
{ |
|||
"fromIndex": 6, |
|||
"targetRuleChainId": { |
|||
"entityType": "RULE_CHAIN", |
|||
"id": "83d42540-85fd-11ea-aee2-794850541ced" |
|||
}, |
|||
"additionalInfo": { |
|||
"layoutX": 1088, |
|||
"layoutY": 203, |
|||
"ruleChainNodeId": "rule-chain-node-9" |
|||
}, |
|||
"type": "True" |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
{ |
|||
"ruleChain": { |
|||
"additionalInfo": null, |
|||
"name": "Thermostat Alarms", |
|||
"firstRuleNodeId": null, |
|||
"root": false, |
|||
"debugMode": false, |
|||
"configuration": null |
|||
}, |
|||
"metadata": { |
|||
"firstNodeIndex": 5, |
|||
"nodes": [ |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 929, |
|||
"layoutY": 67 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.action.TbCreateAlarmNode", |
|||
"name": "Create Temp Alarm", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"alarmType": "High Temperature", |
|||
"alarmDetailsBuildJs": "var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n}\ndetails.triggerValue = msg.temperature;\nreturn details;", |
|||
"severity": "MAJOR", |
|||
"propagate": true, |
|||
"useMessageAlarmData": false, |
|||
"relationTypes": [] |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 930, |
|||
"layoutY": 201 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.action.TbClearAlarmNode", |
|||
"name": "Clear Temp Alarm", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"alarmType": "High Temperature", |
|||
"alarmDetailsBuildJs": "var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n}\nreturn details;" |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 930, |
|||
"layoutY": 131 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.action.TbCreateAlarmNode", |
|||
"name": "Create Humidity Alarm", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"alarmType": "Low Humidity", |
|||
"alarmDetailsBuildJs": "var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n}\ndetails.triggerValue = msg.humidity;\nreturn details;", |
|||
"severity": "MINOR", |
|||
"propagate": true, |
|||
"useMessageAlarmData": false, |
|||
"relationTypes": [] |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 929, |
|||
"layoutY": 275 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.action.TbClearAlarmNode", |
|||
"name": "Clear Humidity Alarm", |
|||
"debugMode": false, |
|||
"configuration": { |
|||
"alarmType": "Low Humidity", |
|||
"alarmDetailsBuildJs": "var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n}\nreturn details;" |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 586, |
|||
"layoutY": 148 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.filter.TbJsSwitchNode", |
|||
"name": "Check Alarms", |
|||
"debugMode": true, |
|||
"configuration": { |
|||
"jsScript": "var relations = [];\nif(metadata[\"ss_alarmTemperature\"] === \"true\"){\n if(msg.temperature > metadata[\"ss_thresholdTemperature\"]){\n relations.push(\"NewTempAlarm\");\n } else {\n relations.push(\"ClearTempAlarm\");\n }\n}\nif(metadata[\"ss_alarmHumidity\"] === \"true\"){\n if(msg.humidity < metadata[\"ss_thresholdHumidity\"]){\n relations.push(\"NewHumidityAlarm\");\n } else {\n relations.push(\"ClearHumidityAlarm\");\n }\n}\n\nreturn relations;" |
|||
} |
|||
}, |
|||
{ |
|||
"additionalInfo": { |
|||
"layoutX": 321, |
|||
"layoutY": 149 |
|||
}, |
|||
"type": "org.thingsboard.rule.engine.metadata.TbGetAttributesNode", |
|||
"name": "Fetch Configuration", |
|||
"debugMode": true, |
|||
"configuration": { |
|||
"clientAttributeNames": [], |
|||
"sharedAttributeNames": [], |
|||
"serverAttributeNames": [ |
|||
"alarmTemperature", |
|||
"thresholdTemperature", |
|||
"alarmHumidity", |
|||
"thresholdHumidity" |
|||
], |
|||
"latestTsKeyNames": [], |
|||
"tellFailureIfAbsent": false, |
|||
"getLatestValueWithTs": false |
|||
} |
|||
} |
|||
], |
|||
"connections": [ |
|||
{ |
|||
"fromIndex": 4, |
|||
"toIndex": 0, |
|||
"type": "NewTempAlarm" |
|||
}, |
|||
{ |
|||
"fromIndex": 4, |
|||
"toIndex": 1, |
|||
"type": "ClearTempAlarm" |
|||
}, |
|||
{ |
|||
"fromIndex": 4, |
|||
"toIndex": 2, |
|||
"type": "NewHumidityAlarm" |
|||
}, |
|||
{ |
|||
"fromIndex": 4, |
|||
"toIndex": 3, |
|||
"type": "ClearHumidityAlarm" |
|||
}, |
|||
{ |
|||
"fromIndex": 5, |
|||
"toIndex": 4, |
|||
"type": "Success" |
|||
} |
|||
], |
|||
"ruleChainConnections": null |
|||
} |
|||
} |
|||
Loading…
Reference in new issue