Report by Exception (RBE) node not working as expected

I would expect 80 to pass then 89 to pass but then 80 should fail. So only keeping the highest value until it's reset.

[
    {
        "id": "781440cf8f7577ec",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8aebf30f.53c138",
        "type": "inject",
        "z": "781440cf8f7577ec",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "r",
        "payload": "80",
        "payloadType": "str",
        "x": 370,
        "y": 260,
        "wires": [
            [
                "26b409ab.f80dae"
            ]
        ]
    },
    {
        "id": "4ff87952.259528",
        "type": "inject",
        "z": "781440cf8f7577ec",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "r",
        "payload": "89",
        "payloadType": "str",
        "x": 370,
        "y": 320,
        "wires": [
            [
                "26b409ab.f80dae"
            ]
        ]
    },
    {
        "id": "40a1a7dc.1e3318",
        "type": "debug",
        "z": "781440cf8f7577ec",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 790,
        "y": 280,
        "wires": []
    },
    {
        "id": "26b409ab.f80dae",
        "type": "rbe",
        "z": "781440cf8f7577ec",
        "name": "",
        "func": "deadband",
        "gap": "1",
        "start": "",
        "inout": "out",
        "septopics": false,
        "property": "payload",
        "topi": "topic",
        "x": 580,
        "y": 280,
        "wires": [
            [
                "40a1a7dc.1e3318"
            ]
        ]
    }
]

No - you have it set


so first 80 goes through... any more 80 values will not- then you send 89... and that goes through...
As it's a valid value them any value that is a change of size more than 1 will trigger it - so 80 is 9 away so that goes through.

So the idea is to use it for a Scale. As you get on the scale the value wil rise. Then it wil peak, as you then get off all the lower values should be blocked as they are not greater than the last valid output.

You could achieve this via a function node.

chrome_LwfwXuKSLM

[{"id":"8f7f9a59772e9c54","type":"inject","z":"23a4d2dd73b6359f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"30.1","payloadType":"num","x":510,"y":600,"wires":[["4b61f945350d10d6"]]},{"id":"4b61f945350d10d6","type":"function","z":"23a4d2dd73b6359f","name":"Max Value Monitor","func":"let max_value = context.get(\"max_value\") || 0;\nconst current_value = msg.payload;\nif(msg.topic == \"CLEAR\") {\n    max_value = 0;\n    context.set(\"max_value\", undefined);\n    node.status({fill:\"grey\",shape:\"ring\",text:\"---\"});\n} else {\n    if (max_value < current_value) {\n        max_value = current_value;\n        context.set(\"max_value\", max_value);\n        msg.payload = max_value;\n        node.status({fill:\"blue\",shape:\"dot\",text: max_value + \" kg\"});\n        return msg;\n    } else {\n        node.status({ fill: \"grey\", shape: \"ring\", text: max_value + \" kg\" });\n    }\n}\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":640,"wires":[["159f9dcabd276f59"]]},{"id":"159f9dcabd276f59","type":"debug","z":"23a4d2dd73b6359f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":950,"y":640,"wires":[]},{"id":"db507ead0e26e1af","type":"inject","z":"23a4d2dd73b6359f","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"CLEAR","x":500,"y":540,"wires":[["4b61f945350d10d6"]]},{"id":"bfc7179f7006d97b","type":"inject","z":"23a4d2dd73b6359f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"37.81","payloadType":"num","x":510,"y":640,"wires":[["4b61f945350d10d6"]]},{"id":"4d2375f2dfe18c0a","type":"inject","z":"23a4d2dd73b6359f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"44.8","payloadType":"num","x":510,"y":680,"wires":[["4b61f945350d10d6"]]},{"id":"6e47c151fc9cae40","type":"inject","z":"23a4d2dd73b6359f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"63.45","payloadType":"num","x":510,"y":720,"wires":[["4b61f945350d10d6"]]}]

@henzard - the flow has been updated to fix a slight issue around the CLEAR operation (credit to @UnborN )

2 Likes

The smooth node can also has a report maximum mode (and can be reset)

1 Like

I must spend some time with the smooth node :thinking:

I'm sure it could benefit from some of your love and attention :slight_smile:

Nice solution ..

it looks like it needs an extra line of code to fully reset on a CLEAR msg
by settings the Context to undefined to clear it and make the code ready for new values

if (msg.topic == "CLEAR") {
    max_value = 0;
    context.set("max_value", undefined);  // reset context
    node.status({ fill: "grey", shape: "ring", text: "---" });
} else {
...
2 Likes

Good spot - was a hurried demo adapted from something else. I'll update the post.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.