From e231f75ac1327ed71023ca5e13c553aec55330e8 Mon Sep 17 00:00:00 2001 From: Justin Otherguy Date: Sat, 8 Jan 2011 12:01:22 +0100 Subject: [PATCH] rounding the values --- lib/Interpreter/MeterInterpreter.php | 2 +- lib/Interpreter/SensorInterpreter.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Interpreter/MeterInterpreter.php b/lib/Interpreter/MeterInterpreter.php index 8cadbcd..017ddfc 100644 --- a/lib/Interpreter/MeterInterpreter.php +++ b/lib/Interpreter/MeterInterpreter.php @@ -83,7 +83,7 @@ class MeterInterpreter extends Interpreter { * @todo reimplement according to new env */ public function getAverage() { - return $this->getConsumption() / ($this->to - $this->from) * 1000; // return W + return round($this->getConsumption() / ($this->to - $this->from) * 1000, 1); // return W } /** diff --git a/lib/Interpreter/SensorInterpreter.php b/lib/Interpreter/SensorInterpreter.php index 0761736..e9bf148 100644 --- a/lib/Interpreter/SensorInterpreter.php +++ b/lib/Interpreter/SensorInterpreter.php @@ -87,7 +87,7 @@ class SensorInterpreter extends Interpreter { * @return float */ public function getLast() { - return (float) $this->conn->fetchColumn('SELECT value FROM data WHERE channel_id = ?' . parent::buildDateTimeFilterSQL($this->from, $this->to). ' ORDER BY timestamp DESC', array($this->channel->getId()), 0); + return round((float) $this->conn->fetchColumn('SELECT value FROM data WHERE channel_id = ?' . parent::buildDateTimeFilterSQL($this->from, $this->to). ' ORDER BY timestamp DESC', array($this->channel->getId()), 0), 1); } /**