Corrently-IoT
Sample flow to store an unsigned integer value to Corrently-IoT
About Corrently IoT
Corrently is an Ethereum Blockchain based ecosystem providing an energy tariff with built-in value creation. In order to allow real digital asset and demand side management Internet of Things provides consensus relevant insides to smart contracts.
More about Corrently
Node-Red Usage
The provided flow simply submits current timestamp to a blockchain account. Replace this Input function with whatever unsinged integer value you like to be available from within the Corrently-Ecosystem. At *STROMDAO we use Node-Red for example to monitor several PV plants.
Hints
Enable persistent context storage in your 'settings.js' (see: https://nodered.org/docs/api/context/ )
The last debug output is a Ethereum style address which represents a digital twin. You might retrieve the value via:
https://app.corrently.de/api/iot?account=ADDRESSHERE
Per definition of Corrently IoT, values will not diretly commited to Ethereum blockchain. Instead they will be kept on hold until condition is met and gas price is covered for thing.
[{"id":"24b29083.a985a","type":"tab","label":"Corrently-IoT-Put","disabled":false,"info":""},{"id":"9fda6cea.921f3","type":"inject","z":"24b29083.a985a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":40,"wires":[["6206ed37.09eb24"]]},{"id":"6206ed37.09eb24","type":"function","z":"24b29083.a985a","name":"Corrently-TwinExist","func":"if(typeof flow.get(\"thing\") != \"undefined\") {\n msg.account = flow.get(\"thing\");\n msg.secret = flow.get(\"secret\");\n msg.registered=1;\n} else {\n msg.registered=0;\n}\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":140,"wires":[["6dbe62a.611279c"]]},{"id":"6dbe62a.611279c","type":"switch","z":"24b29083.a985a","name":"doregistration?","property":"registered","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":140,"wires":[["a8159139.9974f"],["a1234f9c.d19b4"]]},{"id":"a8159139.9974f","type":"function","z":"24b29083.a985a","name":"Corrently-Registration-Builder","func":"msg.urlfix=\"&value=1\";\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":60,"wires":[["34283c8b.8dd064"]]},{"id":"34283c8b.8dd064","type":"http request","z":"24b29083.a985a","name":"Registration-Step1","method":"GET","ret":"obj","url":"https://app.corrently.de/api/iot?{{{urlfix}}}","tls":"","x":930,"y":20,"wires":[["1a5b3b6d.2cb045"]]},{"id":"1a5b3b6d.2cb045","type":"function","z":"24b29083.a985a","name":"Corrently-Secret-Setup","func":"let secret = \"\"+Math.random();\nflow.set(\"secret\",secret);\nmsg.urlfix2=\"&value=2&account=\"+msg.payload.result.account+\"&signature=\"+msg.payload.result.signature+\"&secret=\"+secret;\nreturn msg;","outputs":1,"noerr":0,"x":1060,"y":60,"wires":[["f8d5b6c8.d519a8"]]},{"id":"f8d5b6c8.d519a8","type":"http request","z":"24b29083.a985a","name":"Registration-Step2","method":"GET","ret":"obj","url":"https://app.corrently.de/api/iot?{{{urlfix2}}}","tls":"","x":1210,"y":20,"wires":[["e8cbf3d4.1bbc5"]]},{"id":"e8cbf3d4.1bbc5","type":"function","z":"24b29083.a985a","name":"Finish Registration","func":"if(typeof msg.payload.result != \"undefined\") {\n flow.set(\"thing\",msg.payload.result.account); \n}\nreturn msg;","outputs":1,"noerr":0,"x":1330,"y":60,"wires":[["6206ed37.09eb24"]]},{"id":"a1234f9c.d19b4","type":"function","z":"24b29083.a985a","name":"Corrently-ThingValue","func":"msg.urlfix=\"&value=\"+msg.payload+\"&account=\"+flow.get(\"thing\")+\"&secret=\"+flow.get(\"secret\");\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":240,"wires":[["7337ba32.995a04"]]},{"id":"7337ba32.995a04","type":"http request","z":"24b29083.a985a","name":"Corrently-IoT-Persist","method":"GET","ret":"obj","url":"https://app.corrently.de/api/iot?{{{urlfix}}}","tls":"","x":960,"y":240,"wires":[["cf44c225.3f4ac"]]},{"id":"cf44c225.3f4ac","type":"debug","z":"24b29083.a985a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.result.account","x":1220,"y":240,"wires":[]}]