Skip to content

Instantly share code, notes, and snippets.

@thiseldo
Created November 10, 2013 19:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiseldo/7402637 to your computer and use it in GitHub Desktop.
Save thiseldo/7402637 to your computer and use it in GitHub Desktop.
A quick CurrentCost to Node-RED function to read each channel and split out to topic/payload. Next node could be to publish to a mqtt topic that has already been defined in this node.
var result = msg.payload;
try {
msg.topic="ccost/" + result.msg.sensor;
msg.payload = (result.msg.ch1[0].watts[0])*1;
return msg;
} catch( e )
{
// console.log("Looks like history data");
}
return null;
@crouchingbadger
Copy link

Every time I search for how to do something I come across something succint written by you!
Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment