My node red flow looks like this … you’ll need to sort out your IP addresses, glowstick mac address etc … cut and paste between the ‘[]’ into your nodered
GUI
[
{
"id": "a31e89f5.a102e8",
"type": "tab",
"label": "glowstickMQTTEmoncms",
"disabled": false,
"info": ""
},
{
"id": "fbe2b82f.8d1248",
"type": "mqtt in",
"z": "a31e89f5.a102e8",
"name": "",
"topic": "SMART/HILD/xxxxxxxxxxxx", ### the unique id / mac for your glowstick ###
"qos": "2",
"datatype": "auto",
"broker": "87923771.022e08",
"x": 170,
"y": 280,
"wires": [
[
"4729f673.a2afd8",
"21dcf206.96247e"
]
]
},
{
"id": "a0638792.bb68f8",
"type": "debug",
"z": "a31e89f5.a102e8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 490,
"y": 280,
"wires": []
},
{
"id": "4729f673.a2afd8",
"type": "json",
"z": "a31e89f5.a102e8",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 190,
"y": 360,
"wires": [
[
"93d4ac29.88172"
]
]
},
{
"id": "93d4ac29.88172",
"type": "function",
"z": "a31e89f5.a102e8",
"name": "extract elements",
"func": "msg.meterSerial = msg.payload.elecMtr[\"0702\"][\"03\"][\"08\"]\nmsg.timeStamp = msg.payload.gmtime\nmsg.todayConsumptDelivered0401 = parseInt(msg.payload.elecMtr[\"0702\"][\"04\"][\"01\"],16)\n//msg.instantDemand0400 = parseInt(msg.payload.elecMtr[\"0702\"][\"04\"][\"00\"],16) - value is hex representation of an unsigned INT 24 bits\nmsg.currSummReceived0001 = parseInt(msg.payload.elecMtr[\"0702\"][\"00\"][\"01\"],16)\nmsg.currSummDelivered0000 = parseInt(msg.payload.elecMtr[\"0702\"][\"00\"][\"00\"],16)\n\nmsg.instantDemand0400 = parseInt(msg.payload.elecMtr[\"0702\"][\"04\"][\"00\"],16)\nif ((msg.instantDemand0400 & 0x800000) > 0) {\n msg.instantDemand0400 = msg.instantDemand0400 - 0x1000000\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 330,
"y": 420,
"wires": [
[
"a0638792.bb68f8",
"9ddc9a28.91f898"
]
]
},
{
"id": "9ddc9a28.91f898",
"type": "function",
"z": "a31e89f5.a102e8",
"name": "Send data as emonCMS Input",
"func": "var arrayobj = msg.payload.results\nvar newmsg = {}\nvar apikey =\"xxxxxxxxxxxxxxxxxxxxxxxx\"\n\n// for host if you get a 404 error, this might require 'http://x.x.x.x/emoncms/input/post?'\n// should also work for emoncms.org\n//var host = \"http://192.168.1.xxx/emoncms/input/post?\"\n//http://192.168.1.xxx/input/post?time=1598996829&node=1&csv=100,200,300\n\nvar host = \"http://192.168.1.xxx/emoncms/input/post?\"\nvar node_name = \"glowstick\"\n\n newmsg.url = host\n newmsg.url += \"time=\" + msg.timeStamp\n newmsg.url += \"\\&node=\" + node_name\n newmsg.url += \"\\&csv=\" + msg.instantDemand0400\n newmsg.url += \"\\&apikey=\" + apikey\n \n// newmsg.url += \"\\&fulljson={ \\\"time\\\": \\\"\" + escape(arr[index].interval_end) + \"\\\", \"\n// newmsg.url += \"\\\"consumption\\\": \" + arr[index].consumption + \"}\"\n// newmsg.url += \"\\&apikey=\" + apikey\n// bulk?data=[[-2,%22octopusGo%22,1000],[0,%22octopusGo%22,1000]]&time=1598596010\n //newmsg.url += \"&data=[[0,\\\"\" + node_name + \"\\\",\" + arr[index].consumption + \"]]\"\n //msg.dateconv = new Date(arr[index].interval_end);\n //msg.millisec = Date.parse(arr[index].interval_end);\n //newmsg.url += \"\\&time=\" + msg.millisec;\n ////newmsg.url += \"\\&csv=\" + arr[index].consumption;\n //newmsg.url += \"\\&fulljson={ \\\"time\\\": \\\"\" + escape(arr[index].interval_end) + \"\\\", \"\n //newmsg.url += \"\\\"consumption\\\": \" + arr[index].consumption + \"}\"\n\nreturn newmsg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 630,
"y": 420,
"wires": [
[
"b07cc45e.0b4938",
"bf9d361f.ca5a08"
]
]
},
{
"id": "b07cc45e.0b4938",
"type": "http request",
"z": "a31e89f5.a102e8",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "query",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 710,
"y": 520,
"wires": [
[]
]
},
{
"id": "bf9d361f.ca5a08",
"type": "debug",
"z": "a31e89f5.a102e8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 340,
"wires": []
},
{
"id": "21dcf206.96247e",
"type": "debug",
"z": "a31e89f5.a102e8",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 420,
"y": 200,
"wires": []
},
{
"id": "87923771.022e08",
"type": "mqtt-broker",
"z": "",
"name": "glowstick hildebrand",
"broker": "glowmqtt.energyhive.com",
"port": "8883",
"tls": "",
"clientid": "",
"usetls": true,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]