This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Belevo\EnelixEMS\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$gateway = $test->createInstance(
|
||||
'{B7552FC9-87BC-49D0-8CCB-076BBB045BBE}',
|
||||
'Easee Gateway Test',
|
||||
[
|
||||
'Active' => true,
|
||||
'Testmodus' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$test->runCase('Testgateway ist ohne Zugangsdaten aktiv', static function (
|
||||
TestContext $test
|
||||
) use ($gateway): void {
|
||||
$test->assertInstanceStatus($gateway);
|
||||
$test->assertSame(
|
||||
true,
|
||||
GetValue($test->objectByIdent('Connected', $gateway))
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Abonnement liefert injizierten API-Zustand', static function (
|
||||
TestContext $test
|
||||
) use ($gateway): void {
|
||||
ENELIXEASEE_ProcessStationRequest($gateway, json_encode([
|
||||
'action' => 'Subscribe',
|
||||
'serialNumber' => 'EH123456',
|
||||
], JSON_THROW_ON_ERROR));
|
||||
foreach ([109 => 3, 110 => 30, 120 => 1.0] as $id => $value) {
|
||||
IPS_RequestAction($gateway, 'TestObservation', json_encode([
|
||||
'serialNumber' => 'EH123456',
|
||||
'id' => $id,
|
||||
'value' => $value,
|
||||
], JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
$antwort = json_decode(ENELIXEASEE_ProcessStationRequest(
|
||||
$gateway,
|
||||
json_encode([
|
||||
'action' => 'GetState',
|
||||
'serialNumber' => 'EH123456',
|
||||
], JSON_THROW_ON_ERROR)
|
||||
), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
$test->assertSame(true, $antwort['success']);
|
||||
$test->assertSame(3, $antwort['state']['109']);
|
||||
$test->assertSame(30, $antwort['state']['110']);
|
||||
$test->assertSame(
|
||||
1,
|
||||
GetValue($test->objectByIdent('SubscriptionCount', $gateway))
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Stromvorgabe wird ueber Gateway angenommen', static function (
|
||||
TestContext $test
|
||||
) use ($gateway): void {
|
||||
$antwort = json_decode(ENELIXEASEE_ProcessStationRequest(
|
||||
$gateway,
|
||||
json_encode([
|
||||
'action' => 'SetDynamicChargerCurrent',
|
||||
'serialNumber' => 'EH123456',
|
||||
'amps' => 13,
|
||||
], JSON_THROW_ON_ERROR)
|
||||
), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
$test->assertSame(true, $antwort['success']);
|
||||
$test->assertSame(200, $antwort['httpCode']);
|
||||
});
|
||||
|
||||
$test->runCase('Gebrochene Stromvorgabe wird abgelehnt', static function (
|
||||
TestContext $test
|
||||
) use ($gateway): void {
|
||||
$antwort = json_decode(ENELIXEASEE_ProcessStationRequest(
|
||||
$gateway,
|
||||
json_encode([
|
||||
'action' => 'SetDynamicChargerCurrent',
|
||||
'serialNumber' => 'EH123456',
|
||||
'amps' => 6.5,
|
||||
], JSON_THROW_ON_ERROR)
|
||||
), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
$test->assertSame(false, $antwort['success']);
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Belevo\EnelixEMS\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$gateway = $test->createInstance(
|
||||
'{B7552FC9-87BC-49D0-8CCB-076BBB045BBE}',
|
||||
'Easee Gateway fuer Ladestation',
|
||||
[
|
||||
'Active' => true,
|
||||
'Testmodus' => true,
|
||||
]
|
||||
);
|
||||
$station = $test->createInstance(
|
||||
'{32F65988-BE55-4FD6-9FFF-CF1C4C8628F8}',
|
||||
'Easee Ladestation',
|
||||
[
|
||||
'Betriebsmodus' => 0,
|
||||
'Ladestationskennung' => 'EH123456',
|
||||
'MaximalerLadestrom' => 16,
|
||||
'Ladefreigabe' => true,
|
||||
'Solarladen' => true,
|
||||
'EinstellungenInVisu' => true,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
]
|
||||
);
|
||||
IPS_ConnectInstance($station, $gateway);
|
||||
IPS_ApplyChanges($station);
|
||||
|
||||
$nurSolar = $test->createInstance(
|
||||
'{32F65988-BE55-4FD6-9FFF-CF1C4C8628F8}',
|
||||
'Easee nur Solarladen',
|
||||
[
|
||||
'Betriebsmodus' => 1,
|
||||
'Ladestationskennung' => 'EH654321',
|
||||
'MaximalerLadestrom' => 16,
|
||||
'Ladefreigabe' => true,
|
||||
'Solarladen' => false,
|
||||
'EinstellungenInVisu' => true,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
]
|
||||
);
|
||||
IPS_ConnectInstance($nurSolar, $gateway);
|
||||
IPS_ApplyChanges($nurSolar);
|
||||
|
||||
$sendeBeobachtung = static function (
|
||||
string $seriennummer,
|
||||
int $id,
|
||||
$value
|
||||
) use ($gateway): void {
|
||||
IPS_RequestAction($gateway, 'TestObservation', json_encode([
|
||||
'serialNumber' => $seriennummer,
|
||||
'id' => $id,
|
||||
'value' => $value,
|
||||
], JSON_THROW_ON_ERROR));
|
||||
};
|
||||
|
||||
foreach (['EH123456', 'EH654321'] as $seriennummer) {
|
||||
$sendeBeobachtung($seriennummer, 47, 16.0);
|
||||
$sendeBeobachtung($seriennummer, 104, 32.0);
|
||||
$sendeBeobachtung($seriennummer, 109, 3);
|
||||
$sendeBeobachtung($seriennummer, 110, 30);
|
||||
$sendeBeobachtung($seriennummer, 120, 1.0);
|
||||
$sendeBeobachtung($seriennummer, 182, 2.1);
|
||||
$sendeBeobachtung($seriennummer, 183, 2.0);
|
||||
$sendeBeobachtung($seriennummer, 184, 2.2);
|
||||
}
|
||||
|
||||
$test->runCase('Fahrzeug und drei Phasen folgen direkt den API-Ereignissen', static function (
|
||||
TestContext $test
|
||||
) use ($station): void {
|
||||
$test->assertSame(
|
||||
true,
|
||||
GetValue($test->objectByIdent('FahrzeugVerbunden', $station))
|
||||
);
|
||||
$test->assertSame(
|
||||
3,
|
||||
GetValue($test->objectByIdent('Phasenzahl', $station))
|
||||
);
|
||||
$test->assertSame(
|
||||
3,
|
||||
GetValue($test->objectByIdent('Fahrzeugstatus', $station))
|
||||
);
|
||||
$test->assertEquals(
|
||||
2.2,
|
||||
(float) GetValue($test->objectByIdent('Ladestrom', $station)),
|
||||
0.01
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Event erzeugt ohne Polling ein dreiphasiges Leistungsangebot', static function (
|
||||
TestContext $test
|
||||
) use ($station): void {
|
||||
IPS_RequestAction($station, 'Aktiv', true);
|
||||
$test->assertSame(
|
||||
'[0,4150,4850,5550,6250,6950,7600,8300,9000,9700,10300,11000]',
|
||||
(string) GetValue(
|
||||
$test->objectByIdent('LeistungsangebotDiagnose', $station)
|
||||
)
|
||||
);
|
||||
$test->assertTrue(str_contains(
|
||||
(string) GetValue(
|
||||
$test->objectByIdent('LetzterGeraetebefehl', $station)
|
||||
),
|
||||
'"Ampere":0'
|
||||
));
|
||||
});
|
||||
|
||||
$test->runCase('Nur-Solar-Variante laesst Solarladen nicht abschalten', static function (
|
||||
TestContext $test
|
||||
) use ($nurSolar): void {
|
||||
IPS_RequestAction($nurSolar, 'Solarladen', false);
|
||||
$test->assertSame(
|
||||
true,
|
||||
GetValue($test->objectByIdent('Solarladen', $nurSolar))
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Unbekannter API-Status sperrt die Regelung', static function (
|
||||
TestContext $test
|
||||
) use ($sendeBeobachtung, $station): void {
|
||||
$sendeBeobachtung('EH123456', 109, 99);
|
||||
$test->assertSame(
|
||||
false,
|
||||
GetValue($test->objectByIdent('FahrzeugVerbunden', $station))
|
||||
);
|
||||
$test->assertInstanceStatus($station, 203);
|
||||
|
||||
$sendeBeobachtung('EH123456', 109, 3);
|
||||
$test->assertSame(
|
||||
true,
|
||||
GetValue($test->objectByIdent('FahrzeugVerbunden', $station))
|
||||
);
|
||||
$test->assertInstanceStatus($station);
|
||||
});
|
||||
|
||||
$test->runCase('Gateway-Ausfall verwirft Fahrzeug- und Phasenstatus', static function (
|
||||
TestContext $test
|
||||
) use ($gateway, $station): void {
|
||||
IPS_SetProperty($gateway, 'Active', false);
|
||||
IPS_ApplyChanges($gateway);
|
||||
|
||||
$test->assertSame(
|
||||
false,
|
||||
GetValue($test->objectByIdent('FahrzeugVerbunden', $station))
|
||||
);
|
||||
$test->assertSame(
|
||||
0,
|
||||
GetValue($test->objectByIdent('Phasenzahl', $station))
|
||||
);
|
||||
$test->assertInstanceStatus($station, 202);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user