Skip to content

Commit

Permalink
add Backstop/Rücklaufsperre to power counter (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
1Rolf authored Feb 4, 2025
1 parent 18390d5 commit e37a7c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions EnergyCounterPower/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"name": "Interval",
"type": "IntervalBox",
"caption": "Seconds"
},
{
"name": "Backstop",
"type": "CheckBox",
"caption": "Backstop"
}
]
}
3 changes: 2 additions & 1 deletion EnergyCounterPower/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"Last Value (Temporary": "Letzter Wert (Temporär)",
"Energy Counter (Power)": "Energiezähler (Strom)",
"https://www.symcon.de/en/service/documentation/module-reference/energy-counter/energy-counter-power/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/energiezaehler/energiezaehler-strom/",
"Energy Counter Power": "EnergiezaehlerStrom"
"Energy Counter Power": "EnergiezaehlerStrom",
"Backstop": "Rücklaufsperre"
}
}
}
8 changes: 7 additions & 1 deletion EnergyCounterPower/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public function Create()
$this->RegisterPropertyInteger('SourceVariable', 0);
$this->RegisterPropertyInteger('Voltage', 230);
$this->RegisterPropertyInteger('Interval', 60);
$this->RegisterPropertyBoolean('Backstop', false);

$this->RegisterTimer('UpdateTimer', 0, 'EZS_Update($_IPS[\'TARGET\']);');

$this->RegisterVariableFloat('Current', $this->Translate('Current'), 'Watt.3680', 0);
$this->RegisterVariableFloat('Counter', $this->Translate('Counter'), 'Electricity', 1);

}

public function ApplyChanges()
Expand Down Expand Up @@ -74,8 +76,12 @@ public function Update()
//we use the last updated value to calculate the amount the need to add
$timeDiff = time() - IPS_GetVariable($this->GetIDForIdent('Current'))['VariableUpdated'];

//get current value
//get current value -> if Backstop is active and value is negativ set to 0
$backstop = $this->ReadPropertyBoolean('Backstop');
$currentValue = GetValue($this->GetIDForIdent('Current'));
if ($backstop && ($currentValue < 0)) {
$currentValue = 0;
}

//fetch last counter
$lastCounterValue = GetValue($this->GetIDForIdent('Counter'));
Expand Down

0 comments on commit e37a7c4

Please sign in to comment.