Closed joinke closed 1 year ago
hello @joinke
this is "by design". In the PE version, the device could be assigned to multiple edges, and removal of the device from one edge, should not affect removal from another - that's why in the case of removal from the edge, the device on the cloud is not removed, but unassigned from the edge. CE and PE versions must have similar approaches to handling events - because of this, CE version doesn't remove the device as well - only unassign it from the edge.
If you would like to remove the device from the cloud in case of removal on the edge, you have two possible options.
So it's going to look like this:
So you can add 'Remove Device From Cloud' rule chain, assign it to edge, and modify root rule chain, to push 'Entity Deleted' events into this rule chain. Edge is going to remove device by REST API from the cloud.
https://demo.thingsboard.io/swagger-ui/#/device-controller/deleteDeviceUsingDELETE
Here is the JSON content of 'Delete Device' rule chain:
{ "ruleChain": { "additionalInfo": { "description": "" }, "name": "Remove Device From Cloud", "type": "EDGE", "firstRuleNodeId": null, "root": false, "debugMode": false, "configuration": null, "externalId": null }, "metadata": { "firstNodeIndex": 3, "nodes": [ { "additionalInfo": { "description": "", "layoutX": 518, "layoutY": 453 }, "type": "org.thingsboard.rule.engine.transform.TbTransformMsgNode", "name": "Put token to metadata", "debugMode": true, "configuration": { "jsScript": "metadata.token = msg.token;\nreturn {msg: msg, metadata: metadata, msgType: msgType};" }, "externalId": null }, { "additionalInfo": { "description": "", "layoutX": 679, "layoutY": 273 }, "type": "org.thingsboard.rule.engine.rest.TbRestApiCallNode", "name": "Delete Device from the cloud", "debugMode": true, "configuration": { "restEndpointUrlPattern": "https://demo.thingsboard.io/api/device/${deviceId}", "requestMethod": "DELETE", "useSimpleClientHttpFactory": false, "ignoreRequestBody": null, "enableProxy": false, "useSystemProxyProperties": false, "proxyScheme": null, "proxyHost": null, "proxyPort": 0, "proxyUser": null, "proxyPassword": null, "readTimeoutMs": 0, "maxParallelRequestsCount": 0, "headers": { "Content-Type": "application/json", "X-Authorization": "Bearer ${token}" }, "useRedisQueueForMsgPersistence": false, "trimQueue": false, "maxQueueSize": 0, "credentials": { "type": "anonymous" } }, "externalId": null }, { "additionalInfo": { "description": "", "layoutX": 329, "layoutY": 269 }, "type": "org.thingsboard.rule.engine.rest.TbRestApiCallNode", "name": "Get Bearer", "debugMode": true, "configuration": { "restEndpointUrlPattern": "https://demo.thingsboard.io/api/auth/login", "requestMethod": "POST", "useSimpleClientHttpFactory": false, "ignoreRequestBody": null, "enableProxy": false, "useSystemProxyProperties": false, "proxyScheme": null, "proxyHost": null, "proxyPort": 0, "proxyUser": null, "proxyPassword": null, "readTimeoutMs": 0, "maxParallelRequestsCount": 0, "headers": { "Content-Type": "application/json" }, "useRedisQueueForMsgPersistence": false, "trimQueue": false, "maxQueueSize": 0, "credentials": { "type": "anonymous" } }, "externalId": null }, { "additionalInfo": { "description": "", "layoutX": 165, "layoutY": 456 }, "type": "org.thingsboard.rule.engine.transform.TbTransformMsgNode", "name": "Add your username and password", "debugMode": false, "configuration": { "jsScript": "// put device id into metadata\nmetadata.deviceId = msg.id.id;\n\n\nvar newMsg = {};\nnewMsg.username = \"YOUR_EMAIL\";\nnewMsg.password = \"YOUR_PASSWORD\";\nreturn {msg: newMsg, metadata: metadata, msgType: msgType};" }, "externalId": null } ], "connections": [ { "fromIndex": 0, "toIndex": 1, "type": "Success" }, { "fromIndex": 2, "toIndex": 0, "type": "Success" }, { "fromIndex": 3, "toIndex": 2, "type": "Success" } ], "ruleChainConnections": null } }
Please let me know if you have any additional questions.
Component
Description When I create a Device on Thingsboard Edge, it is created/synced automatically on Thingsboard CE. When I delete the same Device on Thingsboard Edge, it is not deleted on Thingsboard CE.
Environment