Interfacers for MQTT -Solved

Do I need an interfacer in emonhub.conf to utilise the phpmqtt_input.php script as I can't seem to get emoncms to subscribe to MQTT. I've tried various topics without success (rx/ tx/ emonhub/ rx/emoncms/input etc etc). MQTT is working ok as I've written a node-red flow that subscribes to MQTT and forwards data to emoncmcs.org.

I'm running the extended v9 RC2 | 2015.09.15 newly installed on a raspberrypi2 with external HDD.

pb66's picture

Re: Interfacers for MQTT -Solved

No, emonHub shouldn't need to be involved for emonCMS to subscribe to MQTT, but I have no idea what the topic arrangements are off-hand, do you have a MQTT tool that you can use subscribe to the topic(s) published by node-red to confirm they are being published and/or publish something to the emonCMS topic, 

Is there any emoncms (error) logging ? I just wonder if it's possible you have tried the correct topic but the message has not conformed in a way that emoncms can parse it, basically are you sure it's not subscribing or is there just no inputs from MQTT?

Paul 

Bra1n's picture

Re: Interfacers for MQTT -Solved

I'm using MQTT.fx and I can see that topics are being published but I'm seeing nothing in the emoncms.log (well not direct from MQTT at least but plenty from my other emoncms installation which is forwarding to this one via http).

Maybe I'm using the wrong topics, where would I find the correct topics and format ?

pb66's picture

Re: Interfacers for MQTT -Solved

The phpmqtt_input.php script itself is good place to start, but that seems to say it should be "rx/" on line 5 but the examples below that say differently. 

Do you have MQTT enabled in the settings ? and are emoncms, node-red and the mqtt broker all on the same machine? If not have you changed the IP address and also opened the firewall on port 1883 ?

Pau

EDIT - scrap the settings check it seems those mqtt settings might only apply to the publishing from emoncms.

Bra1n's picture

Re: Interfacers for MQTT -Solved

I've stopped the other emoncms updates which were swamping the log and messed with the MQTT publishing data and now I'm seeing "|ERROR|input_controller.php|Format error, json string supplied is not valid" so it looks like the topic and/or format are invalid, Trouble is it keeps repeating periodically even when I'm not sending so I'm unsure which bits to amend. Surely there's some documentation somewhere on the expected topics/format.

EDIT:

The error messages are likely a red herring as they continued even after a reboot then disappeared when I set the other emoncms to continue sending data via http

Paul Reed's picture

Re: Interfacers for MQTT -Solved

How are you keeping phpmqtt_input running? are you running the init script, or just calling it in a SSH session?

Paul

Bra1n's picture

Re: Interfacers for MQTT -Solved

via the init script

Paul Reed's picture

Re: Interfacers for MQTT -Solved

Can you publish to MQTT via the emoncms input process?

To subscribe to a node, I found that 'out of the box' provided that the phpmqtt_input script is running, and MQTT has been enabled in settings.php, that publishing a message in the node format rx/20 will create feed 20 in emoncms and update it accordingly. Doesn't that happen?

Paul

Bra1n's picture

Re: Interfacers for MQTT -Solved

Yes that works so I just need to see what the format is and I'm good to go.

OK sorted, looks like things were much simpler than I realised, thanks for your help

Paul Reed's picture

Re: Interfacers for MQTT -Solved

That's good. I was hoping for a more descriptive topic to subscribe to than rx/ see this post - http://openenergymonitor.org/emon/node/11290

Bra1n's picture

Re: Interfacers for MQTT -Solved

Well I've changed the code in phpmqtt_input.php to use a more descriptive base topic of emoncms/input unfortunately MQTTfx has decide to stop working with an  'Error invoking method." error so I've not tested as yet. Tried MQTT-Spy but I can't get on with it so I'm now looking for another MQTT client/monitor.

Paul Reed's picture

Re: Interfacers for MQTT -Solved

Yes, I tried that too, and found that it didnt work!

Paul

Bra1n's picture

Re: Interfacers for MQTT -Solved

Well it works after a fashion but the code expects the 1st item after the "/" to be the input id and after the next "/" the key so no "/"s allowed in the base topic so I've settled on "emoncms-in" as the base topic. The other point to bear in mind is that because this isn't going via emonhub, forwarding to a remote emoncms doesn't work, but that's ok as I have a node-red flow for that.

Comment viewing options

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