How to Create a Custom Totalizer

I’m resurrecting this topic since it was referenced in Ability to ignore certain input values for totalizers - #8 by mstjohn and, FWIW, I don’t agree with sensij’s comment.

I think OptoMary’s code would work just fine and won’t have any “inflation” as sensij has stated as long as the loop delay is kept less than a second. If the chart takes 50ms to execute as in sensij’s scenario, then the condition will be evaluated 20 times/second - and will only be true for one of those executions which is exactly what is desired.

sensij does make a good point about the modbus delay - you do want to make sure that there isn’t anything in this chart that would cause the execution to go beyond one second, like trying to read an offline device with a large communication timeout setting.