Community
OpenEnergyMonitor

OpenEnergyMonitor Community

A example of EmonCMS sending data to be used in Grafana

Hello all, I’m here to share with you my beta dashboard, build in grafana and with data from EmonCMS. I’m using nodered to write the data from EmonCMS to a Influxdb DataBase, and then build the dashboard in grafana! The result is a pleasing dashboard that I display in a tablet!

The system is new, so the data is still small.

Hope that this can inspire others to think in new implementations :wink:

Best Regards to you all.

5 Likes

Maybe u can show us how u send the data to influxdb??

Hello @mauriciosti, at the moment I’m using NodeRed as a relay to duplicate the data to InfluxDB and then use it in Grafana!

I’m using the NodeRed node node-red-node-emoncms, but I’ll be changing it only to use MQTT.

Hello!
Nice dashboard you have. Can you please share the NodeRed Node used to relay to InfluxDb? This would be a good starting point to replicate something similar.

Thanks!

Hi,
I’m also interrested for a short explanation about this node

This is my nodes in nodered. Probably not the best solution, but it works well to me. In short I read the voltage, watt and kwh (that I did not need, I could calculate in grafana, but its easier) and send it to a InfluxDB. Then I use this data to display in grafana.

[{"id":"545e66fb.ae5378","type":"subflow","name":"Devices / Persistance Service","info":"","category":"","in":[{"x":80,"y":60,"wires":[{"id":"3c28ab26.4612a4"}]}],"out":[]},{"id":"3c28ab26.4612a4","type":"influxdb out","z":"545e66fb.ae5378","influxdb":"723857d4.0da4e8","name":"","measurement":"","precision":"","retentionPolicy":"","x":200,"y":60,"wires":[]},{"id":"723857d4.0da4e8","type":"influxdb","z":"","hostname":"databases.myhome","port":"8086","protocol":"http","database":"nodered","name":"NodeRed","usetls":false,"tls":""},{"id":"19ebdfde.b83ae","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo Casa W","emonServer":"548ec955.705858","feedid":"11","x":730,"y":100,"wires":[["78a3ea47.67c544"]]},{"id":"e7756bbe.f19918","type":"subflow:545e66fb.ae5378","z":"169b9f58.fe0fa1","name":"","x":1830,"y":280,"wires":[]},{"id":"6fb596.43f90a6c","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo Casa KWh","emonServer":"548ec955.705858","feedid":"12","x":740,"y":140,"wires":[["78a3ea47.67c544"]]},{"id":"78a3ea47.67c544","type":"join","z":"169b9f58.fe0fa1","name":"","mode":"auto","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":120,"wires":[["f1a952b6.99cb7"]]},{"id":"7ea56c8b.df0b64","type":"change","z":"169b9f58.fe0fa1","name":"parts","rules":[{"t":"set","p":"parts.id","pt":"msg","to":"_msgid","tot":"msg"},{"t":"set","p":"parts.count","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"voltage","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":280,"wires":[["32591fd7.c1deb","4baf3a0c.e1af34"]]},{"id":"32591fd7.c1deb","type":"change","z":"169b9f58.fe0fa1","name":"parts","rules":[{"t":"set","p":"parts.index","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":260,"wires":[["19ebdfde.b83ae","c24b8f37.a826b","a661e74b.a90008","7bc1e1e8.89627","c7fd01d1.f9876","1da03542.d3290b","c11a1977.e612e8"]]},{"id":"4baf3a0c.e1af34","type":"change","z":"169b9f58.fe0fa1","name":"parts","rules":[{"t":"set","p":"parts.index","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":300,"wires":[["6fb596.43f90a6c","2fd5aca4.fd7024","d08de5b6.7ee8f8","ef94d2e9.33c9e","472d4ec8.41074","5552cbe5.2235d4","657b7532.71ee0c"]]},{"id":"c24b8f37.a826b","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo AC W","emonServer":"548ec955.705858","feedid":"21","x":720,"y":200,"wires":[["9b172eed.77e04"]]},{"id":"2fd5aca4.fd7024","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo AC KWh","emonServer":"548ec955.705858","feedid":"22","x":730,"y":240,"wires":[["9b172eed.77e04"]]},{"id":"9b172eed.77e04","type":"join","z":"169b9f58.fe0fa1","name":"","mode":"auto","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":220,"wires":[["36959a61.b67136"]]},{"id":"f1a952b6.99cb7","type":"change","z":"169b9f58.fe0fa1","name":"Device","rules":[{"t":"set","p":"deviceId","pt":"msg","to":"main","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":120,"wires":[["bedfb4ac.91df48"]]},{"id":"36959a61.b67136","type":"change","z":"169b9f58.fe0fa1","name":"Device","rules":[{"t":"set","p":"deviceId","pt":"msg","to":"air_conditioner","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":220,"wires":[["bedfb4ac.91df48"]]},{"id":"a661e74b.a90008","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo Maquina Roupa W","emonServer":"548ec955.705858","feedid":"23","x":760,"y":300,"wires":[["6c9ad83c.b17788"]]},{"id":"d08de5b6.7ee8f8","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo Maquina Roupa KWh","emonServer":"548ec955.705858","feedid":"24","x":770,"y":340,"wires":[["6c9ad83c.b17788"]]},{"id":"6c9ad83c.b17788","type":"join","z":"169b9f58.fe0fa1","name":"","mode":"auto","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":320,"wires":[["6f07e5dc.71a1bc"]]},{"id":"6f07e5dc.71a1bc","type":"change","z":"169b9f58.fe0fa1","name":"Device","rules":[{"t":"set","p":"deviceId","pt":"msg","to":"washing_machine","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":320,"wires":[["bedfb4ac.91df48"]]},{"id":"7bc1e1e8.89627","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo Maquina Loiça W","emonServer":"548ec955.705858","feedid":"25","x":760,"y":400,"wires":[["86829a26.2943c8"]]},{"id":"86829a26.2943c8","type":"join","z":"169b9f58.fe0fa1","name":"","mode":"auto","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":970,"y":420,"wires":[["d01bac9.228b95"]]},{"id":"d01bac9.228b95","type":"change","z":"169b9f58.fe0fa1","name":"Device","rules":[{"t":"set","p":"deviceId","pt":"msg","to":"dishwasher","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":420,"wires":[["bedfb4ac.91df48"]]},{"id":"bedfb4ac.91df48","type":"function","z":"169b9f58.fe0fa1","name":"Range","func":"var range_arr = [['00:00','08:00'],['22:00','23:59']];\n\nif(msg.time !== undefined)\n    var time = new Date(msg.time);\nelse\n    var time = new Date();\n\nfor(var i=0;i<range_arr.length;i++){\n    if(isInRange(time, range_arr[i])){\n        return [msg,null];\n    }\n}\n\n\nreturn [null,msg];\n\n\nfunction isInRange(value, range) {\n  \n  var time = new Date(value.getTime());\n  time.setSeconds(0);\n  \n  var time_in = new Date(value.getTime());\n  \n  time_in.setHours(range[0].split(':')[0]);\n  time_in.setMinutes(range[0].split(':')[1]);\n  time_in.setSeconds(0);\n  \n  var time_out = new Date(value.getTime());\n  time_out.setHours(range[1].split(':')[0]);\n  time_out.setMinutes(range[1].split(':')[1]);\n  time_out.setSeconds(0);\n  \n  \n  return time.getTime()>=time_in.getTime() && time.getTime()<=time_out.getTime();\n}","outputs":2,"noerr":0,"x":1250,"y":280,"wires":[["518c34d8.5e092c"],["62366904.0b3d58"]]},{"id":"62366904.0b3d58","type":"change","z":"169b9f58.fe0fa1","name":"Set Range","rules":[{"t":"set","p":"trange","pt":"msg","to":"FVZ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1430,"y":320,"wires":[["683d76b7.a627d8"]]},{"id":"518c34d8.5e092c","type":"change","z":"169b9f58.fe0fa1","name":"Set Range","rules":[{"t":"set","p":"trange","pt":"msg","to":"VZ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1430,"y":260,"wires":[["683d76b7.a627d8"]]},{"id":"683d76b7.a627d8","type":"function","z":"169b9f58.fe0fa1","name":"InnoDB","func":"var newMsg = {};\nvar data = {};\nvar tags = {};\n\nif(msg.power !== undefined && msg.kwh !== undefined){\n    var power = msg.power;\n    var kwh   = msg.kwh;\n}\nelse if(msg.payload !== undefined && Array.isArray(msg.payload)){\n    if(msg.payload.length != 2)\n        return null;\n    \n    var power = msg.payload[0];\n    var kwh   = msg.payload[1];\n}\n\nif(power === undefined || kwh === undefined)\n    return null;\n\nnewMsg.measurement = (msg.measurement) || 'power';\n\nif(msg.voltage === undefined)\n    msg.voltage = 24000;\n\ndata = {\n    'power': parseFloat(power),\n    'kwh'  : parseFloat(kwh),\n    'volt' : parseFloat(msg.voltage/100),\n    'amp'  : parseFloat(parseFloat(power) / (msg.voltage/100)),\n}\n\n\nif(msg.time !== undefined)\n    data.time = msg.time;\n\ndata.trange = msg.trange || msg.payload.trange || \"\";\n\ntags.deviceId = msg.deviceId || msg.payload.deviceId;\n\nnewMsg.payload = [data,tags];\n\nreturn newMsg;","outputs":1,"noerr":0,"x":1600,"y":280,"wires":[["e7756bbe.f19918"]]},{"id":"180009d6.24d7a6","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Voltage","emonServer":"548ec955.705858","feedid":"31","x":220,"y":280,"wires":[["7ea56c8b.df0b64"]]},{"id":"3126f0e4.395a4","type":"inject","z":"169b9f58.fe0fa1","name":"Start","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":true,"onceDelay":"60","x":70,"y":280,"wires":[["180009d6.24d7a6"]]},{"id":"ef94d2e9.33c9e","type":"emoncms in","z":"169b9f58.fe0fa1","name":"Consumo Maquina Loiça KWh","emonServer":"548ec955.705858","feedid":"26","x":770,"y":460,"wires":[["86829a26.2943c8"]]},{"id":"548ec955.705858","type":"emoncms-server","z":"","server":"http://debian.myhome/emoncms","name":"EmonCMS Read"}]

Hello :slight_smile:

How to add this to what you posted this way on node-red?
will it work on any emoncms by default?
should do some additional configuration?

Very thanks!

you can read data directly from emoncms link

Thank you for this! I was unaware of this! Where does grafana store’s the pulled Data?

Thank you

Grafana only displays data. That is to say, it doesn’t store data.
Oleg’s method reads the data directly from emonCMS. i.e. emonCMS is where the data is stored.