added sync from linked variable

This commit is contained in:
jhartworks committed 2026-10-21 13:18:45 +02:00
1 parent faa518ccd8
commit ac0621ffe4
6 files changed
+89 -5

No files matched your search

+20
View File
@@ -13,6 +13,7 @@ class EnergyCounterChild extends IPSModule
// nicht im Formular angeboten. Die Childinstanz bleibt reine Anzeige.
$this->RegisterPropertyInteger('ParentInstanceID', 0);
$this->RegisterPropertyString('CounterKey', '');
$this->RegisterPropertyInteger('SourceVariableID', 0);
$this->RegisterPropertyBoolean('ShowTotalEnergy', true);
$this->RegisterPropertyBoolean('ShowTotalCost', true);
@@ -35,6 +36,25 @@ class EnergyCounterChild extends IPSModule
$this->SetStatus(102);
}
/** Setzt die Gesamtenergie über das Hauptmodul auf den aktuellen Zählerstand. */
public function SetTotalEnergyToCurrentSource(): bool
{
$parentInstanceID = $this->ReadPropertyInteger('ParentInstanceID');
$counterKey = $this->ReadPropertyString('CounterKey');
if ($parentInstanceID <= 0 || $counterKey === '') {
IPS_LogMessage('EnergyCounterChild', 'Gesamtenergie kann nicht gesetzt werden: Zuordnung zum Hauptmodul fehlt.');
return false;
}
$function = 'ECM_SetCounterTotalEnergyFromSource';
if (!function_exists($function)) {
IPS_LogMessage('EnergyCounterChild', 'Gesamtenergie kann nicht gesetzt werden: Hauptmodul-Funktion ist nicht verfügbar.');
return false;
}
return $function($parentInstanceID, $counterKey);
}
private function RegisterValueVariables()
{
$this->RegisterVariableFloat('TotalEnergy', $this->Translate('Total Energy'), self::ENERGY_PROFILE, 10);