@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Belevo\EnelixEMS\SymconTest\TestContext;
|
||||
|
||||
return static function (TestContext $test): void {
|
||||
$temperaturId = $test->createVariable(2, 'Boilertemperatur', 52.0, null, '~Temperature');
|
||||
$kontakte = [
|
||||
$test->createActionVariable('Heizstufe 1'),
|
||||
$test->createActionVariable('Heizstufe 2'),
|
||||
$test->createActionVariable('Heizstufe 3'),
|
||||
];
|
||||
$stufen = [];
|
||||
foreach ($kontakte as $index => $kontaktId) {
|
||||
$stufen[] = [
|
||||
'Stufe' => $index + 1,
|
||||
'Leistung' => ($index + 1) * 1000,
|
||||
'Schaltkontakt_Stufe' => $kontaktId,
|
||||
];
|
||||
}
|
||||
|
||||
$verbraucherId = $test->createInstance(
|
||||
'{B7C54AF4-AD7D-4FE4-B75D-203693906251}',
|
||||
'Wassererwärmer',
|
||||
[
|
||||
'Boilerfuehler_PT1' => $temperaturId,
|
||||
'LeistungsStufen' => json_encode($stufen, JSON_THROW_ON_ERROR),
|
||||
'LastwechselSperrzeit' => 1,
|
||||
'LegionellenfunktionAktiv' => false,
|
||||
'DiagnosevariablenAnzeigen' => true,
|
||||
]
|
||||
);
|
||||
$managerId = $test->createInstance(
|
||||
'{6F771B18-59D4-4C8A-B951-3B2FE9F6A2C4}',
|
||||
'Hilfsmanager',
|
||||
[
|
||||
'AutomatischeSuche' => false,
|
||||
'VerbraucherZuordnung' => json_encode([
|
||||
['InstanzID' => $verbraucherId, 'Aktiv' => true],
|
||||
], JSON_THROW_ON_ERROR),
|
||||
]
|
||||
);
|
||||
|
||||
$test->runCase('Instanz und Diagnosevariablen werden angelegt', static function (
|
||||
TestContext $test
|
||||
) use ($verbraucherId): void {
|
||||
$test->assertInstanceStatus($verbraucherId);
|
||||
foreach ([
|
||||
'Aktiv', 'Boilertemperatur', 'Mindesttemperatur', 'Maximaltemperatur',
|
||||
'Istleistung', 'Sollleistung', 'AktiveStufe', 'TemperaturGueltig',
|
||||
] as $ident) {
|
||||
$test->objectByIdent($ident, $verbraucherId);
|
||||
}
|
||||
});
|
||||
|
||||
$test->runCase('Temperaturmessung wird übernommen', static function (TestContext $test) use (
|
||||
$verbraucherId
|
||||
): void {
|
||||
IPS_RequestAction($verbraucherId, 'Aktiv', true);
|
||||
IPS_RequestAction($verbraucherId, 'Melden', true);
|
||||
$temperature = (float) GetValue($test->objectByIdent('Boilertemperatur', $verbraucherId));
|
||||
$test->assertEquals(52.0, $temperature, 0.01);
|
||||
$test->assertSame(
|
||||
true,
|
||||
GetValue($test->objectByIdent('TemperaturGueltig', $verbraucherId))
|
||||
);
|
||||
});
|
||||
|
||||
$test->runCase('Sollwert wählt genau eine Leistungsstufe', static function (
|
||||
TestContext $test
|
||||
) use ($managerId, $verbraucherId, $kontakte): void {
|
||||
$paket = [
|
||||
'Kopf' => [
|
||||
'Version' => '3.0',
|
||||
'AbsenderID' => $managerId,
|
||||
'EmpfaengerID' => $verbraucherId,
|
||||
'Zeitpunkt' => time(),
|
||||
],
|
||||
'Sollleistung_W' => 2000,
|
||||
];
|
||||
IPS_RequestAction(
|
||||
$verbraucherId,
|
||||
'ManagerdatenEmpfangen',
|
||||
json_encode($paket, JSON_THROW_ON_ERROR)
|
||||
);
|
||||
$test->waitUntil(static fn (): bool => GetValue($kontakte[1]) === true);
|
||||
$test->assertSame(
|
||||
[false, true, false],
|
||||
array_map(static fn (int $id): bool => (bool) GetValue($id), $kontakte)
|
||||
);
|
||||
$test->assertSame(
|
||||
2,
|
||||
GetValue($test->objectByIdent('AktiveStufe', $verbraucherId))
|
||||
);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user