Skip to content

Commit

Permalink
Update profiles in ApplyChanges, not Create, thus updating when chang…
Browse files Browse the repository at this point in the history
…ing capacity
  • Loading branch information
DrNiels committed Aug 30, 2024
1 parent 05e6479 commit a59e5de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion BatteryStorage/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"Discharge Power": "Entladeleistung",
"https://www.symcon.de/en/service/documentation/module-reference/virtuelle-devices/batterystorage-simulation/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/virtuelle-geraete/heizstab-simulation/",
"Virtual Battery Storage": "Virtueller Batteriespeicher",
"Kilowatt hours": "Kilowattstunden"
"Kilowatt hours": "Kilowattstunden",
"SoC (Percentage)": "SoC (Prozentual)"
}
}
}
22 changes: 11 additions & 11 deletions BatteryStorage/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ public function Create()
$this->RegisterPropertyInteger('Variance', 6);
$this->RegisterPropertyInteger('Interval', 3);

$this->RegisterVariableFloat('Consumption', $this->Translate('Consumption'), '~Watt');

$this->RegisterTimer('Update', 0, 'VG_Update($_IPS["TARGET"]);');

$this->RegisterTimer('Charge', 1000, 'VG_Charge($_IPS["TARGET"]);');
}

public function ApplyChanges()
{
parent::ApplyChanges();

$profileNamePower = 'ChargeSlider_' . $this->ReadPropertyFloat('Power');
if (!IPS_VariableProfileExists($profileNamePower)) {
IPS_CreateVariableProfile($profileNamePower, VARIABLETYPE_FLOAT);
Expand All @@ -33,20 +44,9 @@ public function Create()
$this->RegisterVariableFloat('DischargePower', $this->Translate('Discharge Power'), $profileNamePower);
$this->EnableAction('DischargePower');

$this->RegisterVariableFloat('Consumption', $this->Translate('Consumption'), '~Watt');

$this->RegisterVariableFloat('SoC', $this->Translate('SoC'), $profileNameCapacity);
$this->EnableAction('SoC');

$this->RegisterTimer('Update', 0, 'VG_Update($_IPS["TARGET"]);');

$this->RegisterTimer('Charge', 1000, 'VG_Charge($_IPS["TARGET"]);');
}

public function ApplyChanges()
{
parent::ApplyChanges();

$this->SetTimerInterval('Update', $this->ReadPropertyInteger('Interval') * 1000);
}

Expand Down

0 comments on commit a59e5de

Please sign in to comment.