105 lines
3.4 KiB
PHP
105 lines
3.4 KiB
PHP
<?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('Ladestart wird ueber Gateway angenommen', static function (
|
|
TestContext $test
|
|
) use ($gateway): void {
|
|
$antwort = json_decode(ENELIXEASEE_ProcessStationRequest(
|
|
$gateway,
|
|
json_encode([
|
|
'action' => 'StartCharging',
|
|
'serialNumber' => 'EH123456',
|
|
], 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']);
|
|
});
|
|
};
|