For future reference, here is the Node Red flow that I used:
[
{
"id": "b520d17bc62281f4",
"type": "mqtt in",
"z": "2984cc27db306d58",
"name": "emonpi_MQTT",
"topic": "Smartplug/Smartplug2/SENSOR/#",
"qos": "2",
"datatype": "auto",
"broker": "cc4085cc0f2a8b60",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 140,
"y": 320,
"wires": [
[
"9cef9887c14df4b4",
"610c90dfed258921"
]
]
},
{
"id": "9cef9887c14df4b4",
"type": "json",
"z": "2984cc27db306d58",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 330,
"y": 380,
"wires": [
[
"ed94099e23c03861",
"043037b642a8f5cf"
]
]
},
{
"id": "ed94099e23c03861",
"type": "debug",
"z": "2984cc27db306d58",
"name": "json payload",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 610,
"y": 240,
"wires": []
},
{
"id": "043037b642a8f5cf",
"type": "function",
"z": "2984cc27db306d58",
"name": "Parse for Emoncms input",
"func": "var newmsg ={};\n\n//Remember to add timezone to date-time string\nvar newDateObj = new Date(msg.payload.Time);\n\ntimeObject = new Date(newDateObj.getTime());\n\ntimeObject = timeObject.getTime()/1000;\n\nnewmsg.time = timeObject;\n\nnewmsg.payload = msg.payload.ENERGY;\n//newmsg.payload.time = msg.payload.Time; // as string\n\nreturn newmsg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 570,
"y": 380,
"wires": [
[
"70ffe13f42e4ccd5",
"771ec034df8b4112"
]
]
},
{
"id": "70ffe13f42e4ccd5",
"type": "debug",
"z": "2984cc27db306d58",
"name": "parsed output",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 860,
"y": 240,
"wires": []
},
{
"id": "610c90dfed258921",
"type": "debug",
"z": "2984cc27db306d58",
"name": "MQTT in",
"active": false,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 370,
"y": 240,
"wires": []
},
{
"id": "771ec034df8b4112",
"type": "mqtt out",
"z": "2984cc27db306d58",
"name": "emonpi_MQTT_push",
"topic": "emon/test/Smartplug2",
"qos": "0",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "cc4085cc0f2a8b60",
"x": 860,
"y": 380,
"wires": []
},
{
"id": "cc4085cc0f2a8b60",
"type": "mqtt-broker",
"name": "",
"broker": "127.0.0.1",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]
I’ve copied shamelessly from @borpin here:
I’ll keep working on the accuracy of the plugs and report that back separately…