|
226 | 226 | // ---------------------------------------------------------------------- |
227 | 227 | config.app = { |
228 | 228 | "title":{"type":"value", "default":"OCTOPUS AGILE", "name": "Title", "description":"Optional title for app"}, |
| 229 | + "currency":{"type":"value", "default":"£", "name": "Currency", "description":"Currency symbol (£, $, ...)"}, |
229 | 230 | "import":{"optional":true, "type":"feed", "autoname":"import", "engine":"5"}, |
230 | 231 | "import_kwh":{"type":"feed", "autoname":"import_kwh", "engine":5}, |
231 | 232 | "use_kwh":{"optional":true, "type":"feed", "autoname":"use_kwh", "engine":5}, |
|
283 | 284 | var data = {}; |
284 | 285 | var graph_series = []; |
285 | 286 | var previousPoint = false; |
286 | | -var viewmode = "graph"; |
287 | | -var viewcostenergy = "energy"; |
288 | 287 | var panning = false; |
289 | 288 | var period_text = "month"; |
290 | 289 | var period_average = 0; |
@@ -413,17 +412,8 @@ function updater() |
413 | 412 | if (config.app[key].value) feeds[key] = result[config.app[key].value]; |
414 | 413 | } |
415 | 414 |
|
416 | | - if (feeds["import"]!=undefined) { |
417 | | - if (viewcostenergy=="energy") { |
418 | | - if (feeds["import"].value<10000) { |
419 | | - $("#power_now").html(Math.round(feeds["import"].value)+"<span class='units'>W</span>"); |
420 | | - } else { |
421 | | - $("#power_now").html((feeds["import"].value*0.001).toFixed(1)+"<span class='units'>kW</span>"); |
422 | | - } |
423 | | - } else { |
424 | | - $("#power_now").html(config.app.currency.value+(feeds["import"].value*1*config.app.unitcost.value*0.001).toFixed(3)+"<span class='units'>/hr</span>"); |
425 | | - } |
426 | | - } |
| 415 | + graph_load() |
| 416 | + graph_draw() |
427 | 417 | }); |
428 | 418 | } |
429 | 419 |
|
@@ -534,17 +524,6 @@ function updater() |
534 | 524 | setTimeout(function() { panning = false; }, 100); |
535 | 525 | }); |
536 | 526 |
|
537 | | -$(".viewcostenergy").click(function(){ |
538 | | - var view = $(this).html(); |
539 | | - if (view=="VIEW COST") { |
540 | | - $(this).html("VIEW ENERGY"); |
541 | | - viewcostenergy = "cost"; |
542 | | - } else { |
543 | | - $(this).html("VIEW COST"); |
544 | | - viewcostenergy = "energy"; |
545 | | - } |
546 | | -}); |
547 | | - |
548 | 527 | $(".energy").click(function() { |
549 | 528 | view_mode = "energy"; |
550 | 529 | graph_draw() |
@@ -961,8 +940,32 @@ function graph_draw() |
961 | 940 | let unit_price = data["agile"][2*this_halfhour_index][1]*1.05; |
962 | 941 | $("#unit_price").html(unit_price.toFixed(2)+"<span class='units'>p</span>"); |
963 | 942 |
|
| 943 | + if (feeds["import"]!=undefined) { |
| 944 | + if (view_mode=="energy") { |
| 945 | + if (feeds["import"].value<10000) { |
| 946 | + $("#power_now").html(Math.round(feeds["import"].value)+"<span class='units'>W</span>"); |
| 947 | + } else { |
| 948 | + $("#power_now").html((feeds["import"].value*0.001).toFixed(1)+"<span class='units'>kW</span>"); |
| 949 | + } |
| 950 | + } else { |
| 951 | + $("#power_now").html(config.app.currency.value+(unit_price*feeds["import"].value*1e-5).toFixed(3)+"<span class='units'>/hr</span>"); |
| 952 | + } |
| 953 | + $("#power_now").show(); |
| 954 | + } |
| 955 | + |
964 | 956 | $(".last_halfhour_stats").show(); |
965 | 957 | } else { |
| 958 | + if (feeds["import"]!=undefined && view_mode=="energy") { |
| 959 | + if (feeds["import"].value<10000) { |
| 960 | + $("#power_now").html(Math.round(feeds["import"].value)+"<span class='units'>W</span>"); |
| 961 | + } else { |
| 962 | + $("#power_now").html((feeds["import"].value*0.001).toFixed(1)+"<span class='units'>kW</span>"); |
| 963 | + } |
| 964 | + $("#power_now").show(); |
| 965 | + } else { |
| 966 | + $("#power_now").hide(); |
| 967 | + } |
| 968 | + |
966 | 969 | $(".last_halfhour_stats").hide(); |
967 | 970 | } |
968 | 971 |
|
|
0 commit comments