fix(ladestation): Solarpause nicht als Ladeende erkennen
This commit is contained in:
@@ -301,7 +301,9 @@ class LadestationStandAlone extends IPSModule implements VerbraucherSchnittstell
|
||||
);
|
||||
$status = LadestationRegler::normalisiereStatus(
|
||||
$rohstatus,
|
||||
$this->ReadAttributeBoolean('ZustandFahrzeugVerbunden')
|
||||
$this->ReadAttributeBoolean('ZustandFahrzeugVerbunden'),
|
||||
$this->ReadAttributeBoolean('ZustandFahrzeugGeladen'),
|
||||
$this->ReadAttributeInteger('LetzterGesetzterStrom') >= 6
|
||||
);
|
||||
|
||||
foreach ($status as $ident => $wert) {
|
||||
|
||||
@@ -34,8 +34,12 @@ final class LadestationRegler
|
||||
* @param array{Rohstatus: int, Istleistung_W: float} $rohstatus
|
||||
* @return array<string, int|float|bool>
|
||||
*/
|
||||
public static function normalisiereStatus(array $rohstatus, bool $warVerbunden): array
|
||||
{
|
||||
public static function normalisiereStatus(
|
||||
array $rohstatus,
|
||||
bool $warVerbunden,
|
||||
bool $warGeladen = false,
|
||||
bool $ladungErwartet = true
|
||||
): array {
|
||||
$verbunden = $rohstatus['Rohstatus'] !== 1;
|
||||
$leistung = max(0.0, $rohstatus['Istleistung_W']);
|
||||
$phasen = self::PHASEN_UNBEKANNT;
|
||||
@@ -47,7 +51,8 @@ final class LadestationRegler
|
||||
$nenner = $phasen === self::PHASEN_EIN ? 230.0 : 1.71 * 400.0;
|
||||
$ladestrom = $leistung / $nenner;
|
||||
$ermittelterMaximalstrom = 2.5 + $ladestrom;
|
||||
$geladen = $warVerbunden && $ermittelterMaximalstrom < 6.0;
|
||||
$geladen = $warGeladen
|
||||
|| ($warVerbunden && $ladungErwartet && $ermittelterMaximalstrom < 6.0);
|
||||
}
|
||||
|
||||
if (!$verbunden) {
|
||||
|
||||
@@ -44,6 +44,28 @@ final class LadestationReglerTest extends TestCase
|
||||
self::assertSame(4, $status['Fahrzeugstatus']);
|
||||
}
|
||||
|
||||
public function testAbsichtlichGestoppteLadungWirdNichtAlsGeladenErkannt(): void
|
||||
{
|
||||
$status = LadestationRegler::normalisiereStatus([
|
||||
'Rohstatus' => 2,
|
||||
'Istleistung_W' => 0.0,
|
||||
], true, false, false);
|
||||
|
||||
self::assertFalse($status['FahrzeugGeladen']);
|
||||
self::assertSame(2, $status['Fahrzeugstatus']);
|
||||
}
|
||||
|
||||
public function testErkanntesLadeendeBleibtBisZumAbsteckenErhalten(): void
|
||||
{
|
||||
$status = LadestationRegler::normalisiereStatus([
|
||||
'Rohstatus' => 2,
|
||||
'Istleistung_W' => 0.0,
|
||||
], true, true, false);
|
||||
|
||||
self::assertTrue($status['FahrzeugGeladen']);
|
||||
self::assertSame(4, $status['Fahrzeugstatus']);
|
||||
}
|
||||
|
||||
public function testBetriebsartUndSolarladenBestimmenDasLeistungsangebot(): void
|
||||
{
|
||||
$solarPV = LadestationRegler::leistungsangebot(true, true, true, false, 1, 16, true, false);
|
||||
|
||||
@@ -61,6 +61,22 @@ return static function (TestContext $test): void {
|
||||
);
|
||||
}
|
||||
|
||||
$solarPause = $test->createInstance(
|
||||
'{0D94913C-0F31-4C29-A685-6EB4AE58E55D}',
|
||||
'Ladestation Solarpause',
|
||||
[
|
||||
'Geraetetyp' => 1,
|
||||
'Geraeteadresse' => '192.0.2.12',
|
||||
'MaximalerLadestrom' => 16,
|
||||
'Ladefreigabe' => true,
|
||||
'Solarladen' => true,
|
||||
'EinstellungenInVisu' => true,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
'Testmodus' => true,
|
||||
'Testantwort' => $goEAntwort(2, 0),
|
||||
]
|
||||
);
|
||||
|
||||
$managerId = $test->createInstance(
|
||||
'{6F771B18-59D4-4C8A-B951-3B2FE9F6A2C4}',
|
||||
'Hilfsmanager Ladestation',
|
||||
@@ -120,6 +136,21 @@ return static function (TestContext $test): void {
|
||||
}
|
||||
});
|
||||
|
||||
$test->runCase('Solarpause wird nicht als Ladeende erkannt', static function (
|
||||
TestContext $test
|
||||
) use ($solarPause): void {
|
||||
IPS_RequestAction($solarPause, 'Solarladen', true);
|
||||
|
||||
$test->assertSame(
|
||||
false,
|
||||
GetValue($test->objectByIdent('FahrzeugGeladen', $solarPause))
|
||||
);
|
||||
$test->assertSame(
|
||||
2,
|
||||
GetValue($test->objectByIdent('Fahrzeugstatus', $solarPause))
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Solar- und Peakbetrieb liefern die Enelix-1-Angebote', static function (
|
||||
TestContext $test
|
||||
) use ($stationen, $anforderungSenden): void {
|
||||
|
||||
Reference in New Issue
Block a user