diff --git a/lib/Definition/EntityDefinition.json b/lib/Definition/EntityDefinition.json index 13a4c7f..57da140 100644 --- a/lib/Definition/EntityDefinition.json +++ b/lib/Definition/EntityDefinition.json @@ -49,7 +49,7 @@ "required" : ["title", "resolution"], "optional" : ["description", "details:", "owner:", "address:", "tolerance", "port", "cuuid", "public", "active"], "icon" : "", // TODO look for an icon - "unit" : "kW", + "unit" : "W", "interpreter" : "Volkszaehler\\Interpreter\\MeterInterpreter", "model" : "Volkszaehler\\Model\\Channel", "translation" : { "de" : "Stromzähler" } @@ -59,7 +59,7 @@ "required" : ["title"], "optional" : ["description", "details:", "owner:", "address:", "tolerance", "port", "cuuid", "public", "active"], "icon" : "", // TODO look for an icon - "unit" : "kW", + "unit" : "W", "interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter", "model" : "Volkszaehler\\Model\\Channel", "translation" : { "de" : "Stromsensor" } @@ -69,7 +69,7 @@ "required" : ["title", "resolution"], "optional" : ["description", "details:", "owner:", "address:", "tolerance", "port", "cuuid", "public", "active"], "icon" : "", // TODO look for an icon - "unit" : "m³/h", + "unit" : "m³", "interpreter" : "Volkszaehler\\Interpreter\\MeterInterpreter", "model" : "Volkszaehler\\Model\\Channel", "translation" : { "de" : "Gas" } @@ -79,7 +79,7 @@ "required" : ["title", "resolution"], "optional" : ["description", "details:", "owner:", "address:", "tolerance", "port", "cuuid", "public", "active"], "icon" : "", // TODO look for an icon - "unit" : "m³/h", + "unit" : "m³", "interpreter" : "Volkszaehler\\Interpreter\\MeterInterpreter", "model" : "Volkszaehler\\Model\\Channel", "translation" : { "de" : "Wasser" } @@ -143,5 +143,15 @@ "interpreter" : "Volkszaehler\\Interpreter\\SensorInterpreter", "model" : "Volkszaehler\\Model\\Channel", "translation" : { "de" : "Lichtstärke" } + }, + { + "name" : "workinghours", + "required" : ["title", "resolution"], + "optional" : ["description", "details:", "owner:", "address:", "tolerance", "public", "active"], + "icon" : "", // TODO look for an icon + "unit" : "h", // TODO add unit + "interpreter" : "Volkszaehler\\Interpreter\\MeterInterpreter", + "model" : "Volkszaehler\\Model\\Channel", + "translation" : { "de" : "Betriebsstundenzähler" } } ] diff --git a/lib/Interpreter/MeterInterpreter.php b/lib/Interpreter/MeterInterpreter.php index 95a9232..c06ab8b 100644 --- a/lib/Interpreter/MeterInterpreter.php +++ b/lib/Interpreter/MeterInterpreter.php @@ -42,12 +42,12 @@ class MeterInterpreter extends Interpreter { /** * Calculates the consumption - * @return float total consumption + * @return float total consumption in Wh */ public function getConsumption() { if (is_null($this->tupleCount)) throw new \Exception('Data has to be processed first!'); - return $this->pulseCount / $this->resolution; + return 1000 * $this->pulseCount / $this->resolution; } /** @@ -75,8 +75,8 @@ class MeterInterpreter extends Interpreter { * @return float */ public function getAverage() { - // 3600: 3600 s/h; 1000: ms -> s; 1000: KW -> W - return (3600 * 1000 * 1000 * $this->getConsumption()) / ($this->to - $this->from); + // 3600: 3600 s/h; 1000: ms -> s + return (3600 * 1000 * $this->getConsumption()) / ($this->to - $this->from); } /**