Skip to content

Commit

Permalink
make import feed optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Trystan Lea committed Mar 25, 2020
1 parent ccf8bdc commit 9360cb5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apps/OpenEnergyMonitor/octopus/octopus.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
// ----------------------------------------------------------------------
config.app = {
"title":{"type":"value", "default":"OCTOPUS AGILE", "name": "Title", "description":"Optional title for app"},
"import":{"type":"feed", "autoname":"import", "engine":"5"},
"import":{"optional":true, "type":"feed", "autoname":"import", "engine":"5"},
"import_kwh":{"type":"feed", "autoname":"import_kwh", "engine":5},
"use_kwh":{"optional":true, "type":"feed", "autoname":"use_kwh", "engine":5},
"solar_kwh":{"optional":true, "type":"feed", "autoname":"solar_kwh", "engine":5},
Expand Down Expand Up @@ -294,14 +294,16 @@ function updater()
if (config.app[key].value) feeds[key] = result[config.app[key].value];
}

if (viewcostenergy=="energy") {
if (feeds["import"].value<10000) {
$("#power_now").html(Math.round(feeds["import"].value)+"<span class='units'>W</span>");
if (feeds["import"]!=undefined) {
if (viewcostenergy=="energy") {
if (feeds["import"].value<10000) {
$("#power_now").html(Math.round(feeds["import"].value)+"<span class='units'>W</span>");
} else {
$("#power_now").html((feeds["import"].value*0.001).toFixed(1)+"<span class='units'>kW</span>");
}
} else {
$("#power_now").html((feeds["import"].value*0.001).toFixed(1)+"<span class='units'>kW</span>");
$("#power_now").html(config.app.currency.value+(feeds["import"].value*1*config.app.unitcost.value*0.001).toFixed(3)+"<span class='units'>/hr</span>");
}
} else {
$("#power_now").html(config.app.currency.value+(feeds["import"].value*1*config.app.unitcost.value*0.001).toFixed(3)+"<span class='units'>/hr</span>");
}
});
}
Expand Down

0 comments on commit 9360cb5

Please sign in to comment.