From e75d89a13585617a02142ec8f36cd301d10d9d6d Mon Sep 17 00:00:00 2001 From: Niels Thole Date: Fri, 8 Mar 2019 17:15:13 +0100 Subject: [PATCH] Fix numeric float conversion --- WasserAlarm/module.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/WasserAlarm/module.php b/WasserAlarm/module.php index 2f32a94..f0c76fd 100644 --- a/WasserAlarm/module.php +++ b/WasserAlarm/module.php @@ -64,8 +64,8 @@ public function ApplyChanges(){ if ($this->ReadPropertyInteger("MeterID") != 0) { $MeterValue = GetValue($this->ReadPropertyInteger("MeterID")); - $this->SetBuffer("LeakBuffer", $MeterValue); - $this->SetBuffer("PipeBurstBuffer", $MeterValue); + $this->SetBuffer("LeakBuffer", json_encode($MeterValue)); + $this->SetBuffer("PipeBurstBuffer", json_encode($MeterValue)); $this->SetTimerInterval("UpdateLeak", $this->ReadPropertyInteger("LeakInterval") * 60 * 1000); $this->SetTimerInterval("UpdatePipeBurst", $this->ReadPropertyInteger("PipeBurstInterval") * 60 * 1000); } @@ -75,17 +75,17 @@ public function ApplyChanges(){ public function CheckAlert(String $ThresholdName, String $BufferName) { $MeterValue = GetValue($this->ReadPropertyInteger("MeterID")); - $ValueOld = $this->GetBuffer($BufferName); + $ValueOld = json_decode($this->GetBuffer($BufferName)); // if Threshold is exceeded -> Set Alert if (($MeterValue - $ValueOld) > GetValueFloat($this->GetIDForIdent($ThresholdName))) { if ($ThresholdName == "LeakThreshold") { SetValue($this->GetIDForIdent("Leak"), GetValueInteger($this->GetIDForIdent("Leak")) + 1); - $this->SetBuffer($BufferName, $MeterValue); + $this->SetBuffer($BufferName, json_encode($MeterValue)); } elseif (GetValueFloat($this->GetIDForIdent($ThresholdName)) != 0) { SetValue($this->GetIDForIdent("PipeBurst"), true); - $this->SetBuffer($BufferName, $MeterValue); + $this->SetBuffer($BufferName, json_encode($MeterValue)); } } @@ -93,11 +93,11 @@ public function CheckAlert(String $ThresholdName, String $BufferName) { else { if ($ThresholdName == "LeakThreshold") { SetValue($this->GetIDForIdent("Leak"), 0); - $this->SetBuffer($BufferName, $MeterValue); + $this->SetBuffer($BufferName, json_encode($MeterValue)); } elseif (GetValueFloat($this->GetIDForIdent($ThresholdName)) != 0) { SetValue($this->GetIDForIdent("PipeBurst"), false); - $this->SetBuffer($BufferName, $MeterValue); + $this->SetBuffer($BufferName, json_encode($MeterValue)); } } }