-
Notifications
You must be signed in to change notification settings - Fork 0
currentcost example
#Currentcost Parser
Simple xml to json parser with two data functions - one just creates Watts and the other an object with both Watts and Temperature.
How-to
-
Install xml2js node - npm install xml2js
-
Reconfigure serial port and baud rate to suit your currentcost device
[{"id":"fc5973ef.a12d38","type":"serial-port","serialport":"/dev/ttyUSB0","serialbaud":"2400","newline":"\r"},{"id":"9a2bd451.c7b198","type":"serial in","name":"","serial":"fc5973ef.a12d38","x":81,"y":2499,"wires":"1d9371bb.0b2396"},{"id":"1d9371bb.0b2396","type":"xml2js","useEyes":false,"name":"","x":247.99994277954102,"y":2542.999918937683,"wires":"39f3d8ad.90ac5","be193883.5bf72"},{"id":"39f3d8ad.90ac5","type":"function","name":"CCost W only","func":"\nvar result = msg.payload;\nmsg.topic="ccost";\nmsg.payload = (result.msg.ch1[0].watts[0])*1;\n\nreturn msg;","outputs":1,"x":402.99999237060547,"y":2508.999917984009,"wires":"437ffa74.c1d904"},{"id":"be193883.5bf72","type":"function","name":"CCost Object","func":"var result = msg.payload;\nvar ccost = new Object;\nccost.id = result.msg.id[0];\nccost.total = (result.msg.ch1[0].watts[0])*1;\nccost.temp = (result.msg.tmpr[0])*1;\n//console.log(ccost);\nmsg.topic="ccost";\nmsg.payload = ccost;\nreturn msg;","outputs":1,"x":406.99992752075195,"y":2567.999917984009,"wires":"2626933.03facec"}]