Get real-time UK power consumption from http://realtimeweb-prod.nationalgrid.com/SystemData.aspx then Tweet with some description.
-
-
Save s0013254/34cb953758976db984a7 to your computer and use it in GitHub Desktop.
UK power consumption to Twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "5d138f6c.a2ec7", | |
"type": "inject", | |
"name": "", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "300", | |
"crontab": "", | |
"once": false, | |
"x": 743, | |
"y": 152, | |
"z": "c3aed0d3.3ce58", | |
"wires": [ | |
[ | |
"496fa39e.b6905c" | |
] | |
] | |
}, | |
{ | |
"id": "496fa39e.b6905c", | |
"type": "http request", | |
"name": "", | |
"method": "GET", | |
"ret": "txt", | |
"url": "http://realtimeweb-prod.nationalgrid.com/SystemData.aspx", | |
"x": 910, | |
"y": 205, | |
"z": "c3aed0d3.3ce58", | |
"wires": [ | |
[ | |
"14d4cb5.feb2b35" | |
] | |
] | |
}, | |
{ | |
"id": "14d4cb5.feb2b35", | |
"type": "function", | |
"name": "UK electricity", | |
"func": "if (~msg.payload.indexOf('<span')) {\n var words = msg.payload.split(\"<p\")[1].split(\"ContentPlaceHolder1\");\n if (words.length >= 3) {\n msg.payload = {};\n msg.payload.demand = parseInt(words[1].split(\">\")[1]);\n msg.payload.frequency = parseFloat(words[3].split(\">\")[1]);\n msg.payload.time = words[2].split(\">\")[1];\n\n // Create the true/false signal based on the frequency.\n frq50 = {};\n frq50.payload = (msg.payload.frequency >= 50) ? true : false;\n\n\tvar toTweet = {};\n\ttoTweet.payload = \"UK power consumption \" + msg.payload.demand +\"MW\" \n\t\t\t\t\t\t+ \" at \" + msg.payload.time.split(\"<\")[0] + \"\\n\"+\n\t\t\t\t\t\t\" (Tweet from Node-RED on Raspberry Pi)\";\n\t\n return [msg,frq50,toTweet];\n }\n}", | |
"outputs": "3", | |
"x": 1070, | |
"y": 112, | |
"z": "c3aed0d3.3ce58", | |
"wires": [ | |
[ | |
"b14aa289.4eb56" | |
], | |
[ | |
"6a27e576.95d81c" | |
], | |
[ | |
"3c9c78bb.c36388" | |
] | |
] | |
}, | |
{ | |
"id": "b14aa289.4eb56", | |
"type": "debug", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "false", | |
"x": 1247, | |
"y": 45, | |
"z": "c3aed0d3.3ce58", | |
"wires": [] | |
}, | |
{ | |
"id": "6a27e576.95d81c", | |
"type": "debug", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "false", | |
"x": 1259, | |
"y": 99, | |
"z": "c3aed0d3.3ce58", | |
"wires": [] | |
}, | |
{ | |
"id": "3c9c78bb.c36388", | |
"type": "twitter out", | |
"twitter": "", | |
"name": "Tweet", | |
"x": 1255, | |
"y": 179, | |
"z": "c3aed0d3.3ce58", | |
"wires": [] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment