Doth-J / node-red-contrib-json-logic

Node-RED node for working with json logic rules and operations in your flow.
https://www.npmjs.com/package/node-red-contrib-json-logic
Apache License 2.0
4 stars 2 forks source link

feedback node #1

Closed tiele closed 11 months ago

tiele commented 11 months ago

examples don't work, the rule node appears as unknown node, ik could replace it manually but I needed it to configure again from scratch, pitty for people who want to quickly check if it does what they want....

I would like to use these rules and also be able to use the context global or flow variables? otherwise the value of this node is not so big as we have to set every variable in the payload manually... probably not so easy to accomplish (need some convention probably) but anyway :)

tiele commented 11 months ago

small sample, here I set all the input manually, but ideally I would like to some of the rules to use the global variables without me needing to set them in the in the payload.

PS for documentation purposes, I seem to be able to combine rules with operations, which is pretty nice functionality (see sample below)

[ { "id": "3d6dfb5d28e3f5a4", "type": "tab", "label": "Flow 5", "disabled": false, "info": "", "env": [] }, { "id": "fd25177842e91c09", "type": "inject", "z": "3d6dfb5d28e3f5a4", "name": "every 15min", "props": [ { "p": "payload" }, { "p": "topic.source", "v": "BR.R4.C4", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "{\"input\":{}}", "payloadType": "json", "x": 190, "y": 360, "wires": [ [ "fb58070a101dcb5f" ] ] }, { "id": "fb58070a101dcb5f", "type": "change", "z": "3d6dfb5d28e3f5a4", "name": "set input", "rules": [ { "t": "set", "p": "payload.input.vbus_relay_1", "pt": "msg", "to": "100", "tot": "str" }, { "t": "set", "p": "payload.input.vbus_relay_4", "pt": "msg", "to": "0", "tot": "str" }, { "t": "set", "p": "payload.input.vbus_temp_2", "pt": "msg", "to": "68", "tot": "num" }, { "t": "set", "p": "payload.input.nibe_bottom", "pt": "msg", "to": "40", "tot": "num" }, { "t": "set", "p": "payload.input.nibe_top", "pt": "msg", "to": "45", "tot": "num" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 380, "y": 360, "wires": [ [ "32cc63650346f757" ] ] }, { "id": "674bf13b846f082b", "type": "debug", "z": "3d6dfb5d28e3f5a4", "name": "allow", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 710, "y": 340, "wires": [] }, { "id": "bc1cff048659df48", "type": "debug", "z": "3d6dfb5d28e3f5a4", "name": "DENY", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 710, "y": 380, "wires": [] }, { "id": "32cc63650346f757", "type": "jsonlogic", "z": "3d6dfb5d28e3f5a4", "name": "rule", "rule": "{\"and\":[{\"==\":[{\"var\":\"input.vbus_relay_1\"},\"100\"]},{\"==\":[{\"var\":\"input.vbus_relay_4\"},\"0\"]},{\">\":[{\"var\":\"input.vbus_temp_2\"},55]},{\"<\":[{\"var\":\"input.nibe_bottom\"},65]},{\">\":[{\"var\":\"input.vbus_temp_2\"},{\"+\":[10,{\"var\":\"input.nibe_top\"}]}]}]}", "ruleType": "json", "mode": "rule", "check": true, "outputs": 2, "outputLabels": [ "", "" ], "x": 530, "y": 360, "wires": [ [ "674bf13b846f082b" ], [ "bc1cff048659df48" ] ] } ]

Doth-J commented 11 months ago

Hello there has been a major update for the logic node, you can now set the rule/operation from various contexts. Check image below:

image

The flow examples have also been updated, in the old examples the logic node was registered with another type that's why it was showing as unknown node, this has been fixed.

tiele commented 11 months ago

jippie, consider me fan of concentrating all business rules in (your) logic node!