Emonhub "pubchannels" and "subchannels" config parameters usage and meaning

I’m using a self hosted version 9.7.8 of emoncms on a raspberry pi2 installed with emonSD.

I have searched everywhere and have not been able to find the purpose or meaning of
pubchannels = ToRFM12,
subchannels = ToEmonCMS,
in the [[MQTT]] section of emonhub and a couple of other places in config files.

I’m using MQTT to post data from a Brultech ECM1240 and everything works fine except that the message to post this info to emoncms.org has no data:
2016-12-24 12:13:32,470 INFO emoncmsorg sending: https://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[]&sentat=1482581612
2016-12-24 12:13:33,929 DEBUG emoncmsorg acknowledged receipt with ‘ok’ from https://emoncms.org

Is “pubchannels” and “subchannels” a construct of MQTT (which I haven’t been able to find) or is it CURRENTLY being used in the emoncms eco-system? Do I need it and if so how do I use it?

The “subchannels” and “pubchannels” are nothing to do with MQTT, they are the internal channels of emonHub, used to route data between certain interfacers.

By sending your data direct to the local emoncms via MQTT you are bypassing emonHub and therefore unable to send to emoncms.org.

What format is your MQTT payload from your Brultech ECM1240 ? I assume it is via a script or node-red perhaps as I see no mention of MQTT in the spec of that device. How is it connected? is it local to the Pi? What is the original output format like?

enonHub is intended to be the HUB for connecting, collating and directing the data. What should happen with an MQTT data source is emonHub subscribes to that source and then forwards it to emonCMS(s) via HTTP or MQTT,

Tell us more about what you have going on and we’ll see if we can help.

Thanks for the quick reply.

The Brutech ECM1240 communicates with BTmon via TCPIP (in my case but serial is also supported)
BTmon was installed on the same rPi2 that was loaded with emonSD.
BTmon can post data directly to emonCMS or to MQTT and many other interfaces.
My configuration has the direct to emonCMS disabled and MQTT enabled

device_list = fc
packet_format = ecm1240bin
device_type = ecm1240
reverse_polarity = true
ip_read = true
ip_poll_interval = 10[source]
device_type = ecm1240
reverse_polarity = true
ip_read = true
ip_poll_interval = 10
ip_host =
ip_port = 8234
ip_mode = client
oem_out = false
oem_token = xxxxxxxxx…xxxxxxxxx
oem_url = http://localhost/emoncms/input/post.json
oem_node = ECM1240
oem_upload_period = 10

I don’t know the format but the data shows up fine in local emoncms inputs
Node 204975_volts
Node … Key… Name …Value
204975_volts… 0… Line Voltage…118.6

I thought the emonhub config gave emonhub all the info needed to grab the MQTT data.
Do I have to create a feed to MQTT for each topic in emomonCMS local so that emonhub can pick it up
to forward to emoncms.org? Why doesn’t emonhub grab all the messages with basetopic the same way
that emonCMS local does?

I see that my problem has been taken up in the following topic:

I will look for a solution there.

The way that MQTT is currently implemented in emonHub and emonCMS doesn’t give a lot of flexibility.

The way MQTT is published so that any authorized software can subscribe to it means that you cannot have emonHub (or any other software) subscribe to the same topic as emoncms AND forward data from other sources to emoncms on the same topic, as that would create an infinite loop.

Data can either be published to 2 separate topics, one for local emonCMS and the other for emonHub to send to remote emonCMS OR alternatively data can be published to one topic which emonHub then forwards to both instances of emonCMS.

Are you able to SSH into the emonPi and show us the output from this command?

mosquitto_sub -v -u 'emonpi' -P 'emonpimqtt2016' -t 'emon/#'

If I can see the MQTT topic and payload format, I may be able to suggest a simple solution.

Here is one packet that was sent to MQTT by btmon:

[email protected](rw):~$ mosquitto_sub -v -u 'emonpi' -P 'emonpimqtt2016' -t 'emon/#'
emon/ECM1240/204975_aux5_dwh 1.176
emon/ECM1240/204975_aux3_dwh 0.647
emon/ECM1240/204975_aux1_dwh 0.004
emon/ECM1240/204975_ch2_dwh -0.059
emon/ECM1240/204975_ch1_dwh 5.912
emon/ECM1240/204975_aux5_wh 947840.016
emon/ECM1240/204975_aux4_wh 601028.981
emon/ECM1240/204975_aux3_wh 199327.451
emon/ECM1240/204975_aux2_wh 62318.347
emon/ECM1240/204975_aux1_wh 247561.274
emon/ECM1240/204975_ch2_wh -11371.365
emon/ECM1240/204975_ch1_wh 6870717.141
emon/ECM1240/204975_aux5_w 384.727
emon/ECM1240/204975_aux3_w 211.818
emon/ECM1240/204975_aux1_w 1.364
emon/ECM1240/204975_ch2_w -19.364
emon/ECM1240/204975_ch1_w 1934.727
emon/ECM1240/204975_volts 120.1

It consists of 2 high current channels, and 5 auxillary channels
each one reports watts, watt-hours and watt-hours / day
as well as the line voltage
(I see some datapoints are missing but that would be at my end)

Paul, your reply suggests I should be able to “Publish to MQTT” a feed with a new topic in emoncms local and have the new topic picked up from the MQTT server and forwarded to emoncms.org.
I have tried to do this but I am missing something.
Publishing the data to “newtopic” shows up fine in MQTT
emonhub is talking to emoncms.org but sending a packet with no data.
Where in the emonhub config file would I specify the “newtopic” for emonhub to subscribe to
Here is what I have in config now:


    Type = EmonHubMqttInterfacer
        mqtt_host =
        mqtt_port = 1883
        mqtt_user = emonpi
        mqtt_passwd = emonpimqtt2016

        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,

        # emonhub/rx/10/values format
        # Use with emoncms Nodes module
        node_format_enable = 0
        node_format_basetopic = emonhub/

        # emon/emontx/power1 format - use with Emoncms MQTT input
        # http://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
        nodevar_format_enable = 1
        nodevar_format_basetopic = emon

    Type = EmonHubEmoncmsHTTPInterfacer
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,
        url = https://emoncms.org
        apikey = xxx........................xxxxc
        senddata = 1                    # Enable sending data to Emoncms.org
        sendstatus = 1                  # Enable sending WAN IP to Emoncms.org MyIP > https://emoncms.org/myip/list
        sendinterval= 60                # Bulk send interval to Emoncms.org in seconds

i’m guessing you mean one batch of packets or one cycle, each of those lines is an individual publish and each has it’s own packet/payload containing just the current value.

This is part of the problem, once the data is separated like that it is difficult to regroup and sending 22 http requests in place of one is not only inefficient for the sender, the network and emonCMS, it causes issues with both the input processing and the timestamping, any delays caused by the high traffic and’or the network will be added to each and every datapoint which means the regular samples become irregular datapoints and are offset with the actual time captured,

That certainly wasn’t my intention, that is most likely the least efficient way of doing it and I’m not sure it would even be possible with the current MQTT implementation in emonHub.

Is the BTMon software able to publish as CSV to one topic? or send to a socket?
Where is this device relative to the emonPi? is the serial connection a possibility?

I see there is mention of a emoncms.org over http configuration for BTMon, could you not just use that to send directly to emoncms.org in parallel with your MQTT rather than trying to regroup the splintered payload or battering emoncms.org with too many requests?

Serial is not an option because the ECM1240 has to be by the electrical service panel and the rPi is at the other end of the house in my office.

I tried to get btmon to post to emoncms.org before without success. I’m going to give that another try now that I have a better understanding of what the data flows are supposed to be…
I had btmon posting directly to emoncms local with http using the oem parameters in the btmon.cfg file.
If it is just a matter of changing the url to emoncms.org and changing the api key - it should work.
I’ll give that a try.