forked from hsenot/empower.me
-
Notifications
You must be signed in to change notification settings - Fork 1
/
getdata.html
442 lines (405 loc) · 19.6 KB
/
getdata.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
<!DOCTYPE html>
<html>
<head>
<title>Empower.me</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrapvalidator/css/bootstrapValidator.min.css"/>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<style>
.well {
margin:10px;
}
.input-lg {
font-size: 22px;
width: 260px;
text-align:center;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Empower.me</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="getdata.html">Get your data</a></li>
<li><a href="visualise.html">Visualise your consumption</a></li>
<li><a href="market.html">Follow the market in real-time</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="contact.html">Contact us</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1>Get your smart meter data</h1>
<p>In Victoria, it's your legal right to access electricity information collected by your utility (section 27.2 of the <a href="http://www.esc.vic.gov.au/getattachment/06661f37-494a-4f8c-8604-7fdf33a27dd2/Energy-Retail-Code-Version-10.pdf" target="_blank">Victorian Energy Retail Code</a>), free of charge and within 10 working days of them receiving the request. Get your data now and start fighting back!</p>
</div>
</div>
<div class="container">
<h1 style="text-align:center;">
<div style="margin-bottom:10px;">
<span class="label label-primary">
Step 1
</span>
</div>
Get your latest bill</h1>
</div>
<div class="container">
<h1 style="text-align:center;">
<div style="margin-bottom:10px;">
<span class="label label-primary">
Step 2
</span>
</div>
Locate your NMI</h1>
<div class="text-center" style="margin-bottom:10px;">
The NMI (National Meter ID) is a 11-digit number. It identifies your smart meter.
<br>
If you need help locating the NMI on your bill, head to <a href="http://www.energytotem.net/find-nmi-meter-serial-number-bill/" target="_blank">EnergyTotem</a> or <a href="http://www.energetics.com.au/services/betterenergymanager/nmis" target="_blank">Energetics</a>. They've got it all covered.
<br>
</div>
<div class="text-center">
<form id="formNMI" class="form-inline" role="form">
<div id="nmiGroup" class="form-group">
<input type="email" class="form-control input-lg" id="nmiInput" name="nmiInput" placeholder="Type your 11-digit NMI">
</div>
</form>
</div>
<br>
<div id="yourUtility" class="text-center">
</div>
</div>
<div class="container" id="retailerContainer" style="display:none;">
<h1 style="text-align:center;">
<div style="margin-bottom:10px;">
<span class="label label-primary">
Step 3
</span>
</div>
Select your retailer</h1>
<div class="text-center">
<form id="formRetailer" class="form-inline" role="form">
<div style="margin:0 auto;float:none; width:250px;font-size:20px;">
<div class="radio text-left" style="display:block;">
<label>
<input type="radio" name="optionsRetailer" id="optionsRadios1" value="AGL">
<div style="width:30px;display:inline-block;" class="text-center"><img src="images/AGL.jpg" height="25"></div> AGL
</label>
</div>
<div class="radio text-left" style="display:block;">
<label>
<input type="radio" name="optionsRetailer" id="optionsRadios2" value="EA">
<div style="width:30px;display:inline-block;" class="text-center"><img src="images/EnergyAustralia.jpg" height="25"></div> Energy Australia
</label>
</div>
<div class="radio text-left" style="display:block;">
<label>
<input type="radio" name="optionsRetailer" id="optionsRadios3" value="OE">
<div style="width:30px;display:inline-block;" class="text-center"><img src="images/OriginEnergy.png" height="25"></div> Origin Energy
</label>
</div>
</div>
</form>
</div>
<br>
<div id="contactURL" class="text-center">
</div>
</div>
<br>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="bootstrapvalidator/js/bootstrapValidator.min.js"></script>
<script>
var nmi_participants;
// IE compatibility for the array filtering function
if (!Array.prototype.filter) {
Array.prototype.filter = function(fun /*, thisp*/) {
var len = this.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var res = [];
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in this) {
var val = this[i]; // in case fun mutates this
if (fun.call(thisp, val, i, this))
res.push(val);
}
}
return res;
};
}
// Convenience string function
function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function digitSum(i){
var sum=0,istr = i.toString();
for (var j=0;j<istr.length;j++)
{
sum += parseInt(istr[j]);
}
return sum;
}
// Implementation adapted from
// https://wiki.openmrs.org/display/docs/Check+Digit+Algorithm
// Test case from:
// http://www.aemo.com.au/Electricity/Policies-and-Procedures/Retail-and-Metering/~/media/Files/Other/electricityops/0610-0008%20pdf.ashx
function luhnCheckDigit(number) {
var validChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVYWXZ_";
number = number.toUpperCase().trim();
var sum = 0;
for (var i = 0; i < number.length; i++) {
var ch = number.charAt(number.length - i - 1);
if (validChars.indexOf(ch) < 0) {
alert("Invalid character(s) found!");
return false;
}
var digit = ch.charCodeAt(0);
var weight;
if (i % 2 == 0) {
weight = (2 * digit);
}
else {
weight = digit;
}
sum += digitSum(weight);
}
sum = Math.abs(sum) + 10;
var digit = (10 - (sum % 10)) % 10;
return digit;
};
// Validating a NMI using a checksum
function isValidNMI(nmi) {
var nmi_str = nmi.toString();
var nmi_without_cs = nmi_str.substring(0,10);
var checksum = parseInt(nmi_str.substring(10,11));
return (luhnCheckDigit(nmi_without_cs) == checksum);
}
// Monitoring the NMI input field
$(document).ready(function() {
$.fn.scrollTo = function( target, options, callback ){
if(typeof options == 'function' && arguments.length == 2){ callback = options; options = target; }
var settings = $.extend({
scrollTarget : target,
offsetTop : 50,
duration : 500,
easing : 'swing'
}, options);
return this.each(function(){
var scrollPane = $(this);
var scrollTarget = (typeof settings.scrollTarget == "number") ? settings.scrollTarget : $(settings.scrollTarget);
var scrollY = (typeof scrollTarget == "number") ? scrollTarget : scrollTarget.offset().top + scrollPane.scrollTop() - parseInt(settings.offsetTop);
scrollPane.animate({scrollTop : scrollY }, parseInt(settings.duration), settings.easing, function(){
if (typeof callback == 'function') { callback.call(this); }
});
});
}
// Retrieving JSON file of NMI allocation
$.getJSON("data/json/nmi_allocation.json",
function(data){
if (data.participants)
{
nmi_participants = data.participants;
}
}
);
$()
// Retailer links
$('input[name="optionsRetailer"]').on('click',function(){
var shortRetailerName = this.value;
var retURL, retLink;
// Correspondance between retailer name and URL to visit
switch (shortRetailerName)
{
case "AGL":
retLink = "AGL Energy Online (portal signup)";
retURL = "https://www.agl.com.au/aeo/home/register";
break;
case "EA":
retLink = "Energy Australia eWise (portal signup)";
retURL = "https://energyaustralia.opower.com/ei/app/account/create";
break;
case "OE":
retLink = "Origin Energy data request form";
retURL = "https://www.originenergy.com.au/3244/Interval-meter-data-request";
break;
default:
alert("Unknown retailer");
}
// Placing the URL to go to in its container
$('#contactURL').html('Go to: <a href="'+retURL+'" target="_blank">'+retLink+'</a>');
$('body').scrollTo('#contactURL');
});
// In all cases, we disable the form submission
$('form').on('submit',function(event){
return false;
});
$('#formNMI').bootstrapValidator({
// The default error message for all fields
message: '',
// Live validating.
live: 'enabled',
// The fields which need to be validated
fields: {
// The field name (value of the "name" attribute)
nmiInput: {
// The default error message for this field
message: ' ',
// Array of validators
validators: {
callback:{
callback: function(fieldValue, validator){
// Clearing error message and message
$('#retailerContainer').css("display","none");
$('#nmiGroup .help-block').html("").css("display","none");
$('#nmiGroup').removeClass("has-success").removeClass("has-error");
$('#yourUtility').html("").css("color","black");
// Checking it's all digits that are being typed
if (fieldValue.length == 0)
{
// Well type something in!
}
else if (!isNumber(fieldValue))
{
$('#nmiGroup').addClass("has-error");
$('#yourUtility').html("Your NMI should only have digits.").css("color","red");
}
else if (fieldValue.length == 1)
{
// Subsetting
var participants_subset = $.grep(nmi_participants, function(e, index){
return e.from.toString().substring(0,1)==fieldValue;
});
// Participant subset join
var result = $.unique(
$.map(participants_subset, function(o) {
return o.state;
})
).join(" or ");
if (result)
{
$('#nmiGroup').addClass("has-success");
$('#yourUtility').html("Someone in "+result+". Keep typing for more details");
}
else
{
$('#nmiGroup').addClass("has-error");
$('#yourUtility').html("Hummm.. No NMI in Australia starts with "+fieldValue+". Is it your NMI you're typing in?").css("color","red");
}
}
else if (fieldValue.length > 1 && fieldValue.length<=11)
{
// Field value to consider
var fv = fieldValue;
if (fv.length==11)
{
fv = fieldValue.substring(0,10);
}
// Subsetting
var participants_subset = $.grep(nmi_participants, function(e, index){
return parseInt(e.from.toString().substring(0,fv.length)) <= parseInt(fv)
&& parseInt(e.to.toString().substring(0,fv.length)) >= parseInt(fv);
});
// Participant subset join
var result = $.unique(
$.map(participants_subset, function(o) {
return o.name;
})
);
if (result.length > 1)
{
//
$('#nmiGroup').addClass("has-success");
$('#yourUtility').html("Keep typing for more details");
}
else if (result.length == 1 || fieldValue.length==11)
{
//
$('#nmiGroup').addClass("has-success");
//
switch(result[0])
{
case "SP-Ausnet DNSP":
$('#yourUtility').html("Go to <b>SP Ausnet</b>'s portal: <a href='https://myhomeenergy.com.au/' target='_blank'>MyHomeEnergy</a>");
$('body').scrollTo('#yourUtility');
break;
case "Jemena Electricity Networks (Vic) Ltd":
$('#yourUtility').html("Go to <b>Jemena</b>'s portal: <a href='https://electricityoutlook.jemena.com.au/' target='_blank'>Electricity Outlook</a>");
$('body').scrollTo('#yourUtility');
break;
case "United Energy Distribution Pty Ltd":
$('#yourUtility').html("Go to <b>United Energy</b>'s portal: <a href='https://energyeasy.ue.com.au/' target='_blank'>Energy Easy</a>");
$('body').scrollTo('#yourUtility');
break;
case "Powercor Australia":
$('#yourUtility').html("Your distributor (<b>Powercor</b>) has delegated smart meter data requests to your retailer. Please proceed to step 3.");
case "CitiPower Pty":
$('#yourUtility').html("Your distributor (<b>CitiPower</b>) has delegated smart meter data requests to your retailer. Please proceed to step 3.");
default:
// Display the 3rd step
$('#retailerContainer').css("display","block");
$('body').scrollTo('#retailerContainer');
}
if (fieldValue.length == 11)
{
// NMI checksum
if (!isValidNMI(fieldValue))
{
$('#nmiGroup').removeClass("has-success").addClass("has-error");
$('#yourUtility').html("The NMI you typed above is not valid. Did you type it correctly?").css("color","red");
}
}
else
{
//$('#yourUtility').html($('#yourUtility').html()+". Keep typing to check your NMI is valid.");
}
} else if (result.length == 0)
{
//
$('#nmiGroup').addClass("has-error");
$('#yourUtility').html("Hummm.. None is in charge of this NMI. Did you type it correctly?").css("color","red");
}
}
else
{
// Too long! Do something about it!
$('#nmiGroup').addClass("has-error");
$('#yourUtility').html("Your NMI cannot be longer than 11 digits.").css("color","red");
setTimeout(function(){
// Does that re-trigger validation?
$('#nmiInput').val(fieldValue.substring(0,11));
$('#formNMI').submit();
},1000);
}
}
}
}
}
}
});
});
</script>
</body>
</html>