OpenEnergyMonitor Community

Update to MQTT Interfacer in emonhub

@trystan has today pushed a change to the MQTT interfacer that I developed. It is currently just in master for testing.

The key change is that a data frame can be published as a single JSON payload and is timestamped. (much like an HTTP data frame) rather than each element of the data frame being sent as separate published topics. This follows on from work I did sometime ago for the emoncms API to accept timestamped JSON payloads.

The main advantage of this is that all the data from one frame uses the same timestamp. In extreme conditions, it was possible for one data item of a frame to be registered against one timeseries slot, and the next item of the same data frame to be registered in the next slot.

The other advantage is reduced processing at both ends as a single MQTT topic is now published/subscribed.

To use this feature on an emonpi stop using the nodevar configuration set it to 0 (or comment out) and include a JSON configuration such as

        # emon/emontx/power1 format - use with Emoncms MQTT input
        # nodevar_format_enable = 0
        # nodevar_format_basetopic = emon/

        # Single JSON payload published  - use with Emoncms MQTT
        node_JSON_enable = 1
        node_JSON_basetopic = emon/

There is no need to restart emonhub.

Other users of emonhub might need to make other adjustments but it should just work.

Any issues, please let me know. It is in the master branch only, for testing right now.


Thanks for your work on this @borpin

1 Like

I like this option.

Is it possible to have values published to MQTT from the Inputs processing in EmonCMS (on EmonPi) also publish in JSON format ? so that all the values as in my MQTT Explorer image below are in JSON format:

Hello @G0LGS

Here’s the line that published the values to MQTT from the emoncms process module:
are you familiar at all with php or programming to be able to modify? perhaps creating a new json format process would be the best way forward, I’d be happy to merge in such a feature if someone is happy to implement and test?