Mqtt en Emoncms

Hey,

I'm trying to get data from my MQTT parser emoncms.
I use the code below.

The MQTT sent data to a log file, but nothing is sent to emoncms. When I manually inject an additive and this pressure will be sent there a correct value.
What am I missing?

 

[{"id":"c3fbe485.3c0418","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"d3c9b77b.2c3648","type":"function","name":"Build emonCMS url","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n// console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n// context = {};\n\n//expects JSON payload and destination specified in topic\n\nvar key = \"MYAPI\";\n\n//destination will be last part node of topic\nvar tokens = msg.topic.split(\"/\");\nvar dest = tokens[tokens.length-1];\n\n\nif(isNaN(dest))\n{\n//not a valid destination\nreturn null;\n}\n\nmsg.url =\"http://emoncms.org/input/post.json?node=\";\nmsg.url += dest;\nmsg.url += \"&json=\";\nmsg.url += msg.payload;\nmsg.url += \"&apikey=\";\nmsg.url += key;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":351.1111068725586,"y":177.33332586288452,"z":"50994439.af66bc","wires":[["23ecf2fc.dc130e"]]},{"id":"23ecf2fc.dc130e","type":"http request","name":"EmonCMS","method":"GET","url":"","x":518.7778091430664,"y":177.3333296775818,"z":
"50994439.af66bc","wires":[["31acd0dc.ce533"]]},{"id":"31acd0dc.ce533","type":"debug","name":"EmonCMS HTTP Request","active":true,"complete":"false","x":711.7778091430664,"y":176.66666173934937,"z":
"50994439.af66bc","wires":[]},{"id":"69caf34d.96350c","type":"mqtt in","name":"Send to Emoncms","topic":"myhome/P2","broker":"c3fbe485.3c0418","x":101.1111068725586,"y":139.99998474121094,
"z":"50994439.af66bc","wires":[["d3c9b77b.2c3648"]]},{"id":"37ce2315.c831dc","type":"inject","name":"","topic":"","payload":"2","payloadType":"string","repeat":
"","crontab":"","once":false,"x":127.77777862548828,"y":224.44444370269775,"z":"50994439.af66bc","wires":[["d3c9b77b.2c3648"]]}]

 

[Edit - Wrapped long lines - Moderator, BT]

Paul Reed's picture

Re: Mqtt en Emoncms

To help us - help you...

You need to tell us more about your system;

  • is it hosted on emoncms.org or self-hosted?
  • ..and if self-hosted what hardware is running it?
  • what is your operating system & emoncms version?

It also helps if you tell us what you have tried to resolve the issue.

Thank you.

Fwerryb4's picture

Re: Mqtt en Emoncms

Hi,

I use a PI2 and send the data to emoncms.org website.
When I manually via a control value node-red and it works but through the brokerMQTT not. When I MQTT broker debug I can see that there is an incoming value.
 

Paul Reed's picture

Re: Mqtt en Emoncms

If you attach a debug node to the function node, can you post the output. (masking your api key!)

Paul

Fwerryb4's picture

Re: Mqtt en Emoncms

This debug output of the MQTT input.

The function node does not give an debug output

5-11-2015 22: 17: 44a3b8fa37.5c4708
myhome / P2: msg: Object
{"Topic": "myhome / P2", "payload": "20", "QoS": 0, "retain": false, "_topic": "myhome / P2", "msgid": "c4ee9ba9.3b1168" }

Fwerryb4's picture

Re: Mqtt en Emoncms

It is solved.
I have all MQTT brokers removed and then it worked.

 

Thanks

Comment viewing options

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