Counter for water filter

Hi, all!

I am new to HA and node-red I need a little help with one flow.
I use a BRITA water filter can on which I put an NFC tag. I would like to use a counter that on every use of the mug (and after every tag scan) to lower my 150L (maximum filter volume in 30 days) by 2.5L and when it reaches 0 to send a message on my phone. In this way I want to know that I do not exceed the liters of water that it can filter. How can I configure the counter node?

I would setup the Counter Node with 15 uses, bound by 15 at the top and 0 at the bottom. Set it up as a decrement counter, and each use will decrement you 1 use from 15. When the counter hits 0 its empty and you need to reset. (I inserted a delay node in case you need it, but honestly, I’d probably leave it out in the real version, you could alternatively have this section fire after your message is sent…)

You’d insert this after Tag ID scanned section to handle he counter branch. then drop your message out at the Do Stuff section.

It will look something like this:

[{"id":"e86b3d7276eaab1a","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"fa620884f9ef7f6f","type":"group","z":"e86b3d7276eaab1a","style":{"stroke":"#3a3a3a","stroke-opacity":"1","fill":"#1e1e1e","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#cccccc"},"nodes":["f6e253ad6d1ce854","729b9707ab9555d8"],"x":874,"y":279,"w":252,"h":122},{"id":"e9806d6d65a31b3d","type":"group","z":"e86b3d7276eaab1a","style":{"stroke":"#3a3a3a","stroke-opacity":"1","fill":"#1e1e1e","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#cccccc"},"nodes":["45a29fb05c75cce3","d9ae34dbb28d49b6"],"x":874,"y":139,"w":252,"h":122},{"id":"e0c20a8173b308c3","type":"group","z":"e86b3d7276eaab1a","style":{"stroke":"#3a3a3a","stroke-opacity":"1","fill":"#1e1e1e","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#cccccc"},"nodes":["dd18402248006d9e","4cc6dff8fa7f5459","f0b9be6a7ff3fb0b"],"x":874,"y":419,"w":392,"h":122},{"id":"631cd4fb3fd188da","type":"counter","z":"e86b3d7276eaab1a","name":"Brita Level (15 uses)","init":"15","step":"1","lower":"0","upper":"1","mode":"decrement","outputs":"1","x":460,"y":400,"wires":[["213ca94bbe24a715"]]},{"id":"213ca94bbe24a715","type":"switch","z":"e86b3d7276eaab1a","name":"msg.count Remain?","property":"count","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":680,"y":400,"wires":[["45a29fb05c75cce3"],["4cc6dff8fa7f5459","f6e253ad6d1ce854"],[]],"outputLabels":["> 0","= 0","ERROR"]},{"id":"6dc41ee937b58714","type":"link in","z":"e86b3d7276eaab1a","name":"link in 11","links":[],"x":125,"y":360,"wires":[["89d7fa0fbc7a2a9b"]]},{"id":"c4116e29c45e5641","type":"comment","z":"e86b3d7276eaab1a","name":"Use Filter Signal In","info":"","x":250,"y":320,"wires":[]},{"id":"89d7fa0fbc7a2a9b","type":"change","z":"e86b3d7276eaab1a","name":"Decrement Counter","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"decrement","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":360,"wires":[["631cd4fb3fd188da"]]},{"id":"f6e253ad6d1ce854","type":"trigger","z":"e86b3d7276eaab1a","g":"fa620884f9ef7f6f","name":"Do Stuff","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":960,"y":360,"wires":[[]]},{"id":"729b9707ab9555d8","type":"comment","z":"e86b3d7276eaab1a","g":"fa620884f9ef7f6f","name":"Counter == 0 Do stuff","info":"","x":1000,"y":320,"wires":[]},{"id":"45a29fb05c75cce3","type":"trigger","z":"e86b3d7276eaab1a","g":"e9806d6d65a31b3d","name":"Report Stuff","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":970,"y":220,"wires":[[]]},{"id":"d9ae34dbb28d49b6","type":"comment","z":"e86b3d7276eaab1a","g":"e9806d6d65a31b3d","name":"Counter > 0 Report stuff","info":"","x":1000,"y":180,"wires":[]},{"id":"dd18402248006d9e","type":"change","z":"e86b3d7276eaab1a","g":"e0c20a8173b308c3","name":"Reset Counter to 15","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"reset","pt":"msg","to":"15","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1140,"y":460,"wires":[["631cd4fb3fd188da"]]},{"id":"4cc6dff8fa7f5459","type":"delay","z":"e86b3d7276eaab1a","g":"e0c20a8173b308c3","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":960,"y":460,"wires":[["dd18402248006d9e"]]},{"id":"f0b9be6a7ff3fb0b","type":"comment","z":"e86b3d7276eaab1a","g":"e0c20a8173b308c3","name":"Reset Counter","info":"","x":970,"y":500,"wires":[]}]

Thank you very much for your time to explain. Your code works as it should work :pray: