Hello There! I need your help.
I am trying to get difference between Previous Data and Current Data. I have tried with context node.
Now what Happing is It works ok for once only and then I get error. I think I have made some mistake with data type but unable to resolve.
[{"id":"85423cdf.8e07f","type":"change","z":"214cbd01.8af412","name":"set topic to agg1","rules":[{"t":"set","p":"topic","pt":"msg","to":"curr","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":560,"wires":[["677873f7.82ab6c","cf9f0474.07f2d8"]]},{"id":"4039ce14.44862","type":"change","z":"214cbd01.8af412","name":"payload.agg1 + payload.agg2","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload.curr) - $number(payload.prev)\t","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1140,"y":620,"wires":[["536999d.b8fd568","a5c8aa80.d58638","d637c9f.3694638"]]},{"id":"4f354b15.4e8194","type":"change","z":"214cbd01.8af412","name":"set topic to agg2","rules":[{"t":"set","p":"topic","pt":"msg","to":"prev","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":680,"wires":[["677873f7.82ab6c","b108c855.393e38"]]},{"id":"e11c8bdc.3ef608","type":"comment","z":"214cbd01.8af412","name":"Subtraction","info":"","sticky":0,"x":170,"y":480,"wires":[]},{"id":"7a612da9.171364","type":"debug","z":"214cbd01.8af412","name":"","active":true,"console":"false","xaxis":"","complete":"payload","x":1150,"y":700,"wires":[]},{"id":"b108c855.393e38","type":"debug","z":"214cbd01.8af412","name":"","active":true,"console":"false","xaxis":"","complete":"payload","x":950,"y":740,"wires":[]},{"id":"536999d.b8fd568","type":"debug","z":"214cbd01.8af412","name":"gauge data","active":true,"console":false,"complete":"payload","x":1390,"y":540,"wires":[]},{"id":"cf9f0474.07f2d8","type":"debug","z":"214cbd01.8af412","name":"","active":true,"console":"false","xaxis":"","complete":"payload","x":990,"y":560,"wires":[]},{"id":"3944171b.baf578","type":"extract parameter","z":"214cbd01.8af412","name":"Agg1_Current_Weight","topic":"ded1a0bfec43400f970e566f8263c6d3/BatchMix/Agg1_Current_Weight","topicData":"{\"asset\":\"ded1a0bfec43400f970e566f8263c6d3\",\"assetName\":\"BatchMix\",\"aspect\":\"403f8515fd754ad298be50f5146fd9a8\",\"aspectName\":\"BatchMix\",\"variable\":\"TN96ba993b8c6f\",\"variableName\":\"Agg1_Current_Weight\"}","parameter":"Agg1_Current_Weight","x":480,"y":560,"wires":[["85423cdf.8e07f","36d72933.1be666"]]},{"id":"677873f7.82ab6c","type":"join","z":"214cbd01.8af412","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","x":930,"y":620,"wires":[["4039ce14.44862","7a612da9.171364"]]},{"id":"9c122cbc.a9f8c","type":"read timeseries","z":"214cbd01.8af412","name":"Agg1_Current_Weight","topic":"ded1a0bfec43400f970e566f8263c6d3/BatchMix/Agg1_Current_Weight","topicLabel":"BatchMix/BatchMix/Agg1_Current_Weight","topicData":"{\"asset\":\"ded1a0bfec43400f970e566f8263c6d3\",\"assetName\":\"BatchMix\",\"aspects\":[{\"aspectId\":\"403f8515fd754ad298be50f5146fd9a8\",\"aspectName\":\"BatchMix\",\"variables\":[{\"variableId\":\"TN96ba993b8c6f\",\"name\":\"Agg1_Current_Weight\"}]}]}","assetName":"","selectedTopics":"","period":"60","offset":"0","mode":"lastValue","from":"","datetimepickerFrom":"","to":"","datetimepickerTo":"","timezoneoffset":0,"x":240,"y":560,"wires":[["3944171b.baf578"]]},{"id":"230f813b.7a6bbe","type":"read-context","z":"214cbd01.8af412","name":"","key":"Pre","context":"flow","x":510,"y":680,"wires":[["4f354b15.4e8194","641d0732.c03358"]],"_type":"node"},{"id":"d637c9f.3694638","type":"store-context","z":"214cbd01.8af412","name":"","key":"Pre","context":"flow","x":1430,"y":620,"wires":[],"_type":"node"},{"id":"24e1fd6f.4559a2","type":"ui_button","z":"214cbd01.8af412","name":"","group":"ef93e993.0b1d48","order":0,"width":0,"singleBrowser":false,"height":0,"passthru":false,"label":"button_Subtraction of curr1&prev","color":"","bgcolor":"","icon":"","payload":"[65]","payloadType":"json","topic":"","powerMode":false,"x":180,"y":620,"wires":[["9c122cbc.a9f8c","230f813b.7a6bbe","6c45261f.f00cb8"]]},{"id":"a5c8aa80.d58638","type":"ui_text","z":"214cbd01.8af412","group":"ef93e993.0b1d48","order":0,"width":0,"singleBrowser":false,"height":0,"name":"","label":"Difference","format":"{{msg.payload}}","layout":"row-spread","x":1380,"y":700,"wires":[]},{"id":"36d72933.1be666","type":"ui_text","z":"214cbd01.8af412","group":"ef93e993.0b1d48","order":0,"width":0,"singleBrowser":false,"height":0,"name":"","label":"Current Value","format":"{{msg.payload}}","layout":"row-spread","x":740,"y":460,"wires":[]},{"id":"641d0732.c03358","type":"ui_text","z":"214cbd01.8af412","group":"ef93e993.0b1d48","order":0,"width":0,"singleBrowser":false,"height":0,"name":"","label":"Previous Value","format":"{{msg.payload}}","layout":"row-spread","x":740,"y":740,"wires":[]},{"id":"ef93e993.0b1d48","type":"ui_group","z":"","name":"Calculate Difference","tab":"951888b5.904548","order":2,"disp":true,"width":"6","collapse":false,"_type":"config"},{"id":"951888b5.904548","type":"ui_tab","z":"","name":"Old data","icon":"dashboard","order":2,"publicAccess":"true","fmAccess":"none","fmAccessType":"private","assetType":"","asset":"","assetName":"","assetText":"","image":"","description":"","hideTitleBar":false,"_type":"config"}]