Skip to content

Commit d7b81c5

Browse files
committed
Change slowupdate() to update cost properly
Addresses emoncms#174 by branching on the viewmode, and applying the unit cost to the kWh
1 parent beed61f commit d7b81c5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

apps/OpenEnergyMonitor/myelectric/myelectric.php

+10-4
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ function slowupdate()
510510
{
511511
var use = config.app.use.value;
512512
var use_kwh = config.app.use_kwh.value;
513-
513+
var unitcost = config.app.unitcost.value;
514+
514515
var interval = 86400;
515516
var now = new Date();
516517
var end = Math.floor(now.getTime() * 0.001);
@@ -524,10 +525,15 @@ function slowupdate()
524525
}
525526

526527
if (usetoday_kwh!==null) {
527-
if (usetoday_kwh<100) {
528-
$("#usetoday").html((usetoday_kwh).toFixed(1));
528+
if (viewmode == "energy") {
529+
if (usetoday_kwh<100) {
530+
$("#usetoday").html((usetoday_kwh).toFixed(1));
531+
} else {
532+
$("#usetoday").html((usetoday_kwh).toFixed(0));
533+
}
529534
} else {
530-
$("#usetoday").html((usetoday_kwh).toFixed(0));
535+
var cost_today = usetoday_kwh*unitcost;
536+
$("#usetoday").html((cost_today).toFixed(2));
531537
}
532538
} else {
533539
$("#usetoday").html("---");

0 commit comments

Comments
 (0)