Activate MQTT emonHub ?

How do I activate MQTT publish from emonHub? 

I have this i in the emonHub config file:

### This interfacer manages the RFM2Pi module
[[MQTT]]

    Type = EmonHubMqttInterfacer
    [[[init_settings]]]
        mqtt_host = 127.0.0.1
        mqtt_port = 1883
    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,
        basetopic = emonhub/

And this is what I see in the emonhub.log file when starting my RasberyPi (with firmware vlow-write-v8.5):

2015-06-17 14:40:50,002 INFO     MainThread EmonHub Pre-Release Development Version (rc2.0?)
2015-06-17 14:40:50,005 INFO     MainThread Opening hub...
2015-06-17 14:40:50,008 INFO     MainThread Logging level set to DEBUG
2015-06-17 14:40:50,010 INFO     MainThread Creating EmonHubJeeInterfacer 'RFM2Pi'
2015-06-17 14:40:50,016 DEBUG    MainThread Opening serial port: /dev/ttyAMA0 @ 9600 bits/s
2015-06-17 14:40:52,029 INFO     MainThread RFM2Pi device firmware version & configuration: not available
2015-06-17 14:40:52,036 INFO     MainThread Setting RFM2Pi frequency: 868 (8b)
2015-06-17 14:40:53,044 INFO     MainThread Setting RFM2Pi group: 210 (210g)
2015-06-17 14:40:54,048 INFO     MainThread Setting RFM2Pi quiet: 0 (0q)
2015-06-17 14:40:55,052 INFO     MainThread Setting RFM2Pi baseid: 5 (5i)
2015-06-17 14:40:56,056 INFO     MainThread Setting RFM2Pi calibration: 230V (1p)
2015-06-17 14:40:57,060 DEBUG    MainThread Setting RFM2Pi subchannels: ['ToRFM12']
2015-06-17 14:40:57,063 DEBUG    MainThread Interfacer: Subscribed to channel' : ToRFM12
2015-06-17 14:40:57,072 DEBUG    MainThread Setting RFM2Pi pubchannels: ['ToEmonCMS']
2015-06-17 14:40:57,079 DEBUG    MainThread Interfacer: Subscribed to channel' : ToRFM12
2015-06-17 14:40:57,093 INFO     MainThread Creating EmonHubMqttInterfacer 'MQTT'
2015-06-17 14:40:57,102 INFO     MainThread MQTT Init mqtt_host=127.0.0.1 mqtt_port=1883
2015-06-17 14:40:57,126 DEBUG    RFM2Pi     acknowledged command: > 8b
2015-06-17 14:40:57,166 DEBUG    MainThread MQTT Subscribed to channel' : ToEmonCMS
2015-06-17 14:40:57,176 INFO     MainThread Creating EmonHubEmoncmsHTTPInterfacer 'emoncmsorg'
2015-06-17 14:40:57,182 DEBUG    MainThread emoncmsorg Subscribed to channel' : ToEmonCMS
2015-06-17 14:40:57,292 INFO     MQTT       Connecting to MQTT Server
2015-06-17 14:40:57,318 INFO     MQTT       connection status: Connection successful
2015-06-17 14:40:57,322 DEBUG    MQTT       CONACK => Return code: 0
2015-06-17 14:40:57,348 DEBUG    RFM2Pi     acknowledged command: > 210g
2015-06-17 14:40:57,433 INFO     MQTT       on_subscribe
2015-06-17 14:40:57,562 DEBUG    RFM2Pi     acknowledged command: > 0q
2015-06-17 14:40:57,667 DEBUG    RFM2Pi     acknowledged command: > 5i
2015-06-17 14:40:57,873 DEBUG    RFM2Pi     acknowledged command: > 1p
2015-06-17 14:40:58,389 DEBUG    RFM2Pi     acknowledged command: <nn> i     - set node ID (standard node ids are 1..26)

 

To me it looks like the connection to the mqtt broker starts ok but I don't see any publishing in my mqtt viwer.

pb66's picture

Re: Activate MQTT emonHub ?

"To me it looks like the connection to the mqtt broker starts ok but I don't see any publishing in my mqtt viwer."

I would agree with that, but there doesn't appear to be any data frames shown so is there anything to publish?

Try passing some data to emonHub via the RFM2Pi to see if it gets published.

Paul

maze42's picture

Re: Activate MQTT emonHub ?

I think I'am passing data, below is a recent part of my emonHub log. At least the feeds in EmonCMS are updated, but I don't see any messages from EmomHub in my MQTT viewer.

2015-06-26 06:29:54,313 DEBUG    RFM2Pi     2205 Timestamp : 1435300194.31
2015-06-26 06:29:54,316 DEBUG    RFM2Pi     2205 From Node : 10
2015-06-26 06:29:54,318 DEBUG    RFM2Pi     2205    Values : [4, 2, 2, 252.17000000000002]
2015-06-26 06:29:54,322 INFO     RFM2Pi     Publishing: emonhub/rx/10/values 4,2,2,252.17
2015-06-26 06:29:54,327 DEBUG    RFM2Pi     2205 adding frame to buffer => [1435300194, 10, 4, 2, 2, 252.17000000000002]
2015-06-26 06:29:54,330 DEBUG    RFM2Pi     2205 Sent to channel' : ToEmonCMS
2015-06-26 06:30:04,064 INFO     emoncmsorg sending: http://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[[1435300194,10,4,2,2,252.17000000000002]]&sentat=1435300204
2015-06-26 06:30:04,173 DEBUG    emoncmsorg acknowledged receipt with 'ok' from http://emoncms.org
2015-06-26 06:30:04,387 INFO     emoncmsorg sending: http://emoncms.org/myip/set.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2015-06-26 06:30:28,755 DEBUG    RFM2Pi     2206 NEW FRAME : 10 3 0 4 0 3 0 41 98
2015-06-26 06:30:28,760 DEBUG    RFM2Pi     2206 Timestamp : 1435300228.75
2015-06-26 06:30:28,762 DEBUG    RFM2Pi     2206 From Node : 10
2015-06-26 06:30:28,765 DEBUG    RFM2Pi     2206    Values : [3, 4, 3, 251.29]
2015-06-26 06:30:28,768 INFO     RFM2Pi     Publishing: emonhub/rx/10/values 3,4,3,251.29
2015-06-26 06:30:28,774 DEBUG    RFM2Pi     2206 adding frame to buffer => [1435300228, 10, 3, 4, 3, 251.29]
2015-06-26 06:30:28,776 DEBUG    RFM2Pi     2206 Sent to channel' : ToEmonCMS
2015-06-26 06:30:34,075 INFO     emoncmsorg sending: http://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[[1435300228,10,3,4,3,251.29]]&sentat=1435300234
2015-06-26 06:30:34,195 DEBUG    emoncmsorg acknowledged receipt with 'ok' from http://emoncms.org
2015-06-26 06:30:34,460 DEBUG    RFM2Pi     2207 NEW FRAME : 10 2 0 5 0 2 0 49 98
2015-06-26 06:30:34,466 DEBUG    RFM2Pi     2207 Timestamp : 1435300234.46
2015-06-26 06:30:34,468 DEBUG    RFM2Pi     2207 From Node : 10
2015-06-26 06:30:34,471 DEBUG    RFM2Pi     2207    Values : [2, 5, 2, 251.37]
2015-06-26 06:30:34,474 INFO     RFM2Pi     Publishing: emonhub/rx/10/values 2,5,2,251.37
2015-06-26 06:30:34,480 DEBUG    RFM2Pi     2207 adding frame to buffer => [1435300234, 10, 2, 5, 2, 251.37]
2015-06-26 06:30:34,482 DEBUG    RFM2Pi     2207 Sent to channel' : ToEmonCMS
2015-06-26 06:31:04,098 INFO     emoncmsorg sending: http://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[[1435300234,10,2,5,2,251.37]]&sentat=1435300264
2015-06-26 06:31:04,216 DEBUG    emoncmsorg acknowledged receipt with 'ok' from http://emoncms.org
2015-06-26 06:31:04,419 INFO     emoncmsorg sending: http://emoncms.org/myip/set.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y
2015-06-26 06:31:34,153 INFO     emoncmsorg sending: http://emoncms.org/input/bulk.json?apikey=E-M-O-N-C-M-S-A-P-I-K-E-Y&data=[]&sentat=1435300294
2015-06-26 06:31:34,254 DEBUG    emoncmsorg acknowledged receipt with 'ok' from http://emoncms.org

pb66's picture

Re: Activate MQTT emonHub ?

Yes it does look like you are publishing eg "Publishing: emonhub/rx/10/values 2,5,2,251.37" is your viewer definitely working? can you see other topics?

Are you running a local emoncms? is that updating or are you only using emoncms.org?

maze42's picture

Re: Activate MQTT emonHub ?

Yes, i can see topics from other mqtt nodes on my net. I'm running a local emoncms as well and the feeds are updated there.

pb66's picture

Re: Activate MQTT emonHub ?

If the local emoncms is getting data then MQTT must be working unless you have created another interfacer, I.m not able to explain why you are not seeing the data in your viewer as I'm not overly clued up on the MQTT stuff.

Paul

maze42's picture

Re: Activate MQTT emonHub ?

Problem SOLVED!

I had forgot to change the "mqtt_host" parameter from 127.0.0.1 to the IP for my mqtt broker machine. As I was editing the raspberry pi/emonhub config from my mqtt broker machine I didn't give that fact a second thought.

BUT the thing that mislead me was the fact that emonHub reported successful connection in the log file!

.....
2015-06-17 14:40:57,292 INFO     MQTT       Connecting to MQTT Server
2015-06-17 14:40:57,318 INFO     MQTT       connection status: Connection successful
2015-06-17 14:40:57,322 DEBUG    MQTT       CONACK => Return code: 0
2015-06-17 14:40:57,348 DEBUG    RFM2Pi     acknowledged command: > 210g
2015-06-17 14:40:57,433 INFO     MQTT       on_subscribe
....

With this setup:

### This interfacer manages the RFM2Pi module
[[MQTT]]

    Type = EmonHubMqttInterfacer
    [[[init_settings]]]
        mqtt_host = 127.0.0.1
        mqtt_port = 1883
    [[[runtimesettings]]]
        pubchannels = ToRFM12,
        subchannels = ToEmonCMS,
        basetopic = emonhub/

 

Is there a mqtt broker running on the Pi?

 

pb66's picture

Re: Activate MQTT emonHub ?

Yes there is, so if emonhub is now publishing to another MQTT broker I'm guessing the local emoncms must of stopped updating or have you changed the broker details in emoncms too?

Paul

maze42's picture

Re: Activate MQTT emonHub ?

I'm no linux guy so I don't know how to change  anything in emoncms even if I want :-).

I don't think it will do any harm if that broker are running anyway so i think I just let it be for know.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.