Created
February 1, 2018 16:34
-
-
Save natcl/24ad3144a239193af118d2e921d611b3 to your computer and use it in GitHub Desktop.
Node-RED + Jsonata: Add/delete from object without a function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"da36d92a.fdbea","type":"comment","z":"f3e76b7c.c6075","name":"init flow.devices to empty object","info":"","x":190,"y":60,"wires":[]},{"id":"7fae03dc.30d794","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"A","payload":"{\"host\":\"A\",\"status\":\"online\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":260,"wires":[["6b94ce72.3e99b8"]]},{"id":"45b494a3.7dfc5c","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"B","payload":"{\"host\":\"B\",\"status\":\"online\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["6b94ce72.3e99b8"]]},{"id":"6b94ce72.3e99b8","type":"change","z":"f3e76b7c.c6075","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t payload.host : payload\t}\t ","tot":"jsonata"},{"t":"set","p":"devices","pt":"flow","to":"$merge([$flowContext('devices'), payload])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":260,"wires":[["bd51b33d.be3048"]]},{"id":"3ca957ff.ea9b98","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":150,"y":120,"wires":[["60cd0da5.f79e24"]]},{"id":"60cd0da5.f79e24","type":"change","z":"f3e76b7c.c6075","name":"","rules":[{"t":"set","p":"devices","pt":"flow","to":"{}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":120,"wires":[[]]},{"id":"ac8843cf.caef5","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"","payload":"devices","payloadType":"flow","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":580,"wires":[["398bab08.b67054"]]},{"id":"398bab08.b67054","type":"debug","z":"f3e76b7c.c6075","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":371.25,"y":581.25,"wires":[]},{"id":"bd51b33d.be3048","type":"debug","z":"f3e76b7c.c6075","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":260,"wires":[]},{"id":"8ef43ddf.4b6a78","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"","payload":"A","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":420,"wires":[["d5a36e12.550188"]]},{"id":"6e34c046.4518c8","type":"inject","z":"f3e76b7c.c6075","name":"","topic":"","payload":"B","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":460,"wires":[["d5a36e12.550188"]]},{"id":"d5a36e12.550188","type":"change","z":"f3e76b7c.c6075","name":"","rules":[{"t":"set","p":"devices","pt":"flow","to":"$sift($flowContext('devices'), function($v, $k){$k != payload})","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":420,"wires":[["df079ac9.dc5c08"]]},{"id":"df079ac9.dc5c08","type":"debug","z":"f3e76b7c.c6075","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":420,"wires":[]},{"id":"22e9fc05.8b4184","type":"comment","z":"f3e76b7c.c6075","name":"Add to flow.devices","info":"","x":150,"y":200,"wires":[]},{"id":"fd74167f.1041e8","type":"comment","z":"f3e76b7c.c6075","name":"Remove from flow.devices","info":"","x":170,"y":360,"wires":[]},{"id":"b406c99d.61772","type":"comment","z":"f3e76b7c.c6075","name":"Print flow.devices","info":"","x":140,"y":520,"wires":[]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment