spacemanspiff2007 / sml2mqtt

Sml to MQTT Bridge
GNU General Public License v3.0
25 stars 8 forks source link

Default behaviour for publishing over MQTT #31

Closed baiti closed 1 year ago

baiti commented 1 year ago

Recently when expermimenting with the config, I had removed the diff filter accidentally and I had assumed that the every: 30 I had set would result in one packet every 30s delivered to MQTT. To my surprise, I got 1 packet per second! As it seems, without a diff filter, packets get emitted "on change". That means, even when the power reading, for instance, changes by 1 Watt, a packet goes out. Is that really a meaningful default behaviour? I am now back to setting: diff: 10000. All I want is a periodic sample rate, no exceptions, therefore the large value on diff now.

        # Filters control how often a value is published over mqtt.
        # If one filter is true the value will be published
        filters:
        - diff: 10      # report if value difference is >= 10
        - perc: 10      # report if percentage change is >= 10%
        - every: 120    # report at least every 120 secs (overrides the value from general)
spacemanspiff2007 commented 1 year ago

If you pass the -a switch you'll see that there will be a diff filter auto generated which reports on every change.

baiti commented 1 year ago

If you pass the -a switch you'll see that there will be a diff filter auto generated which reports on every change.

Of course.

The question is more one of: Is this a meaningful default if no diff filter has been explicitly defined in the config? From my perspective, if I put in an every 30 and nothing else, I'd expect messages be sent via MQTT once every 30s, no exceptions.

Autogenerating a diff filter "on every change" is an unexpected behaviour and I'd be surprised if it didn't irritate more users than just me.

For me it is now ok the way it is as I will put a detailed comment into my config that reminds me of that behaviour whenever I touch that config perhaps in months down the road.

Thank you very much for a very useful tool and best regards.

spacemanspiff2007 commented 1 year ago

From my perspective, if I put in an every 30 and nothing else, I'd expect messages be sent via MQTT once every 30s, no exceptions.

You're right, maybe I have to think more about it.