mqtt_lua
mqtt_lua copied to clipboard
Added "delay" option for rate limiting
The label is not final (I don't like the term "delay" in this context) but this is a functional proof of concept at least
I like where this is going. I propose that we attempt something more flexible ...
Command line argument is "-r rule_expression" or "--rule rule_expression", where the equivalent to your code would be "--rule period=10" (instead of "-d 10"). This will allow a variety of rules to be applied in the future.
The rule handling code in your callback would be moved into a library "rules.lua", which would contain the rule expression parser and a "rule_check(rule_expression)" function, which indicates whether the rule conditions have been met (and then publishing the message should occur). This means that the rules could be used by many applications / examples without having to duplicate code in every callback.
In time, the various rules may become extensible plug-ins.