No offence to anyone who uses or prefers JSONata, but I am in the other camp - preferring to do data manipulation in JS.
I find JS is far easier to read, there are an order of magnitude more developers who know JS vs JSONata, JS is almost always faster than JSONata, the JS editor has much richer help and last, but certainly not least, I simply cannot get to grips with JSONata for much more than simple manipulations.
YMMV.
PS: here is how I'd do it based on my suggestion (post #2 in this thread)
[{"id":"1455b1df33f53d9c","type":"rbe","z":"3642c7ee286f9c17","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload.contact","topi":"topic","x":910,"y":380,"wires":[["2f67febae08fe331"]]},{"id":"1e4ee8196628f73d","type":"debug","z":"3642c7ee286f9c17","name":"complete msg","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1220,"y":440,"wires":[]},{"id":"2dac0a1c3d22ee99","type":"inject","z":"3642c7ee286f9c17","name":"true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"battery\":100,\"battery_low\":false,\"contact\":true,\"linkquality\":64,\"tamper\":false,\"voltage\":3000}","payloadType":"json","x":750,"y":340,"wires":[["1455b1df33f53d9c"]]},{"id":"da13e457cd5b1f10","type":"inject","z":"3642c7ee286f9c17","name":"false","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"battery\": 100, \"battery_low\": false, \"contact\": false, \"linkquality\": 64, \"tamper\": false, \"voltage\": 3000 }","payloadType":"json","x":750,"y":380,"wires":[["1455b1df33f53d9c"]]},{"id":"704f852b3b6204d2","type":"function","z":"3642c7ee286f9c17","name":"resetable counter","func":"let count = context.get('count') || 0\ncount++\n\nif (msg.reset) {\n count = 0\n node.status({});\n} else {\n node.status({fill:\"green\",shape:\"dot\",text:\"count:\" + count});\n}\n\ncontext.set('count', count)\n\nif (!msg.reset) {\n msg.count = count\n return msg\n}\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":990,"y":440,"wires":[["1e4ee8196628f73d","7cf195ce14c87f11"]]},{"id":"7cf195ce14c87f11","type":"debug","z":"3642c7ee286f9c17","name":"msg.count","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"count ? count : 0","statusType":"jsonata","x":1210,"y":480,"wires":[]},{"id":"6bbd0c05aaea631d","type":"inject","z":"3642c7ee286f9c17","name":"reset","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":750,"y":480,"wires":[["704f852b3b6204d2","7cf195ce14c87f11"]]},{"id":"2f67febae08fe331","type":"switch","z":"3642c7ee286f9c17","name":"payload.contact === true?","property":"payload.contact","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":1090,"y":380,"wires":[["704f852b3b6204d2"]]}]