This commit is contained in:
+47
-2
@@ -86,6 +86,8 @@ class Batterie extends IPSModule implements VerbraucherSchnittstelle
|
||||
$this->RegisterPropertyFloat('ReserveLadezustand', 20.0);
|
||||
$this->RegisterPropertyFloat('MindestLadezustand', 10.0);
|
||||
$this->RegisterPropertyFloat('LadezustandHysterese', 2.0);
|
||||
$this->RegisterPropertyBoolean('NachladenMitMaximalleistung', true);
|
||||
$this->RegisterPropertyInteger('MaximaleNachladeleistung', 0);
|
||||
$this->RegisterPropertyInteger('MesswertMaxAlter', 60);
|
||||
$this->RegisterPropertyInteger('Aenderungssperre', 4);
|
||||
$this->RegisterPropertyBoolean('DiagnosevariablenAnzeigen', false);
|
||||
@@ -185,6 +187,11 @@ class Batterie extends IPSModule implements VerbraucherSchnittstelle
|
||||
$formular['elements'],
|
||||
$this->ReadPropertyInteger('Batterietyp')
|
||||
);
|
||||
$this->setzeFormfeldSichtbar(
|
||||
$formular['elements'],
|
||||
'MaximaleNachladeleistung',
|
||||
!$this->ReadPropertyBoolean('NachladenMitMaximalleistung')
|
||||
);
|
||||
|
||||
return json_encode($formular, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
@@ -251,6 +258,14 @@ class Batterie extends IPSModule implements VerbraucherSchnittstelle
|
||||
$this->aktualisiereFormRegisterfelder((int) $wert);
|
||||
return;
|
||||
|
||||
case 'FormNachladenMitMaximalleistung':
|
||||
$this->UpdateFormField(
|
||||
'MaximaleNachladeleistung',
|
||||
'visible',
|
||||
!(bool) $wert
|
||||
);
|
||||
return;
|
||||
|
||||
case 'ManagerdatenEmpfangen':
|
||||
if (!is_string($wert)) {
|
||||
throw new InvalidArgumentException(
|
||||
@@ -382,7 +397,10 @@ class Batterie extends IPSModule implements VerbraucherSchnittstelle
|
||||
$messwerte['Netzleistung'],
|
||||
$messwerte['Istleistung'],
|
||||
$messwerte['MaxLaden'],
|
||||
$messwerte['MaxEntladen']
|
||||
$messwerte['MaxEntladen'],
|
||||
$this->ReadPropertyBoolean('NachladenMitMaximalleistung')
|
||||
? null
|
||||
: (float) $this->ReadPropertyInteger('MaximaleNachladeleistung')
|
||||
)
|
||||
: [0];
|
||||
|
||||
@@ -776,6 +794,14 @@ class Batterie extends IPSModule implements VerbraucherSchnittstelle
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->ReadPropertyBoolean('NachladenMitMaximalleistung')
|
||||
&& $this->ReadPropertyInteger('MaximaleNachladeleistung') <= 0
|
||||
) {
|
||||
throw new InvalidArgumentException(
|
||||
'MaximaleNachladeleistung muss groesser als 0 W sein.'
|
||||
);
|
||||
}
|
||||
|
||||
BatterieRegler::hystereseAktiv(
|
||||
50.0,
|
||||
$this->ReadPropertyFloat('ReserveLadezustand'),
|
||||
@@ -793,7 +819,10 @@ class Batterie extends IPSModule implements VerbraucherSchnittstelle
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
1.0,
|
||||
$this->ReadPropertyBoolean('NachladenMitMaximalleistung')
|
||||
? null
|
||||
: (float) $this->ReadPropertyInteger('MaximaleNachladeleistung')
|
||||
);
|
||||
|
||||
foreach (self::MESSWERT_PROPERTIES as $property) {
|
||||
@@ -1096,6 +1125,22 @@ class Batterie extends IPSModule implements VerbraucherSchnittstelle
|
||||
$this->setzeZustand('Stoertext', $text);
|
||||
}
|
||||
|
||||
/** @param array<int, mixed> $elemente */
|
||||
private function setzeFormfeldSichtbar(
|
||||
array &$elemente,
|
||||
string $name,
|
||||
bool $sichtbar
|
||||
): void {
|
||||
foreach ($elemente as &$element) {
|
||||
if (($element['name'] ?? '') === $name) {
|
||||
$element['visible'] = $sichtbar;
|
||||
}
|
||||
if (isset($element['items']) && is_array($element['items'])) {
|
||||
$this->setzeFormfeldSichtbar($element['items'], $name, $sichtbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @param array<int, mixed> $elemente */
|
||||
private function setzeRegisterfelderSichtbar(
|
||||
array &$elemente,
|
||||
|
||||
Reference in New Issue
Block a user