Before and after values for rbe node

#1

For the Report by Exception node, I get the message that caused a change. However, I would like to know the previous message also so that I can handle the 'nature' of the change.

Currently, before every node.send(msg) the node.previous[t] is over-written by the current message. Perhaps, that value can be part of the msg so that, whenever there is a change, both before and after values are carried forward.

Any thoughts on how to obtain the before and after values?

0 Likes

#2

You could store the previous value you were sent ?

0 Likes

#3

Yes, I am using context in a function as shown below. Wish this was automatic ... :wink:

[{"id":"a2c8992b.21d768","type":"tab","label":"Demo","disabled":false,"info":""},{"id":"7404d9e4.091858","type":"inject","z":"a2c8992b.21d768","name":"t1a","topic":"t1","payload":"{"a":1}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":260,"wires":[["1d5feafc.29a7bd"]]},{"id":"6c87246e.68217c","type":"inject","z":"a2c8992b.21d768","name":"t1b","topic":"t1","payload":"{"a":2}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":340,"wires":[["1d5feafc.29a7bd"]]},{"id":"1d5feafc.29a7bd","type":"rbe","z":"a2c8992b.21d768","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":280,"y":300,"wires":[["e2497972.200528","16c74adb.ea230d"]]},{"id":"e2497972.200528","type":"debug","z":"a2c8992b.21d768","name":"rbe","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":450,"y":240,"wires":[]},{"id":"16c74adb.ea230d","type":"function","z":"a2c8992b.21d768","name":"Ctx","func":"var rbe = {};\n\nif (context.get('rbe') === undefined) {\n context.set('rbe', msg.payload)\n rbe = msg.payload\n} else {\n rbe = context.get('rbe');\n}\nmsg.payload = rbe;\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":300,"wires":[["c74e698e.3ecb48"]]},{"id":"c74e698e.3ecb48","type":"debug","z":"a2c8992b.21d768","name":"ctx","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":610,"y":300,"wires":[]}]

0 Likes