Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

Commit

Permalink
Merge pull request #15 from symcon/fix/wasseralarm
Browse files Browse the repository at this point in the history
Fix numeric float conversion
  • Loading branch information
SomeSymconUser authored Mar 11, 2019
2 parents b2e8405 + e75d89a commit 6cb200f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions WasserAlarm/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -75,29 +75,29 @@ 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));
}

}
// if Threshold is not exceeded -> reset Alert
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));
}
}
}
Expand Down

0 comments on commit 6cb200f

Please sign in to comment.