This commit is contained in:
@@ -6,6 +6,7 @@ const ENELIX_DEMO_ROOT_IDENT = 'ENELIX_DEMO_2';
|
||||
const ENELIX_DEMO_MANAGER_MODULE = '{6F771B18-59D4-4C8A-B951-3B2FE9F6A2C4}';
|
||||
const ENELIX_DEMO_BOILER_MODULE = '{B7C54AF4-AD7D-4FE4-B75D-203693906251}';
|
||||
const ENELIX_DEMO_SINGLE_MODULE = '{15879A4E-D0C2-4495-83DE-46E1E462591E}';
|
||||
const ENELIX_DEMO_DUMMY_MODULE = '{485D0419-BE97-4548-AA9C-C083EB82E61E}';
|
||||
const ENELIX_DEMO_TILE_MODULE = '{B5B875BB-9B76-45FD-4E67-2607E45B3AC4}';
|
||||
const ENELIX_DEMO_ARCHIVE_MODULE = '{43192F0B-135B-4CE7-A0A7-1475603F3060}';
|
||||
const ENELIX_DEMO_ENERGY_DISTRIBUTION_MODULE = '{BA90FDB3-C203-8F26-B4D6-F3DB99905724}';
|
||||
@@ -37,12 +38,14 @@ function enelixDemoInstall(): array
|
||||
$boiler2Power = enelixDemoEnsureVariable($dashboard, 'Boiler2Leistung', 'Boiler 2 Leistung', 2, 'ENELIX.Demo.PowerPositive', 0.0, 70);
|
||||
$dryerPower = enelixDemoEnsureVariable($dashboard, 'EntfeuchterLeistung', 'Entfeuchter Leistung', 2, 'ENELIX.Demo.PowerPositive', 0.0, 80);
|
||||
|
||||
$powerChart = enelixDemoEnsureVariable($history, 'Leistungsdiagramm', 'Leistungsverlauf', 3, '~HTMLBox', '', 10);
|
||||
$energyChart = enelixDemoEnsureVariable($history, 'Energiediagramm', 'Kumulierte Energien', 3, '~HTMLBox', '', 20);
|
||||
$pvEnergy = enelixDemoEnsureVariable($history, 'PVEnergie', 'PV-Energie', 2, 'ENELIX.Demo.Energy', 0.0, 30);
|
||||
$houseEnergy = enelixDemoEnsureVariable($history, 'HausEnergie', 'Hausverbrauch Energie', 2, 'ENELIX.Demo.Energy', 0.0, 40);
|
||||
$gridImportEnergy = enelixDemoEnsureVariable($history, 'NetzbezugEnergie', 'Netzbezug Energie', 2, 'ENELIX.Demo.Energy', 0.0, 50);
|
||||
$gridExportEnergy = enelixDemoEnsureVariable($history, 'EinspeisungEnergie', 'Einspeisung Energie', 2, 'ENELIX.Demo.Energy', 0.0, 60);
|
||||
$powerChart = enelixDemoEnsureVariable($history, 'Leistungsdiagramm', 'Leistungsverlauf (Legacy)', 3, '~HTMLBox', '', 90);
|
||||
$energyChart = enelixDemoEnsureVariable($history, 'Energiediagramm', 'Kumulierte Energien (Legacy)', 3, '~HTMLBox', '', 100);
|
||||
IPS_SetHidden($powerChart, true);
|
||||
IPS_SetHidden($energyChart, true);
|
||||
$pvEnergy = enelixDemoEnsureVariable($history, 'PVEnergie', 'PV-Energie', 2, '~Electricity', 0.0, 30);
|
||||
$houseEnergy = enelixDemoEnsureVariable($history, 'HausEnergie', 'Hausverbrauch Energie', 2, '~Electricity', 0.0, 40);
|
||||
$gridImportEnergy = enelixDemoEnsureVariable($history, 'NetzbezugEnergie', 'Netzbezug Energie', 2, '~Electricity', 0.0, 50);
|
||||
$gridExportEnergy = enelixDemoEnsureVariable($history, 'EinspeisungEnergie', 'Einspeisung Energie', 2, '~Electricity', 0.0, 60);
|
||||
|
||||
$auto = enelixDemoEnsureVariable($simulation, 'Automatik', 'Tageslauf automatisch', 0, '~Switch', true, 10);
|
||||
$hour = enelixDemoEnsureVariable($simulation, 'Tageszeit', 'Simulierte Tageszeit', 2, 'ENELIX.Demo.Hour', 8.0, 20);
|
||||
@@ -89,6 +92,21 @@ function enelixDemoInstall(): array
|
||||
$chartUpdated = enelixDemoEnsureVariable($technical, 'LetztesDiagrammUpdate', 'Letztes Diagramm-Update', 1, '', 0, 170);
|
||||
IPS_SetHidden($chartUpdated, true);
|
||||
|
||||
$flowPv = enelixDemoEnsureVariable($technical, 'EnergieflussPVkW', 'PV-Leistung', 2, '~Power', 0.0, 300);
|
||||
$flowGrid = enelixDemoEnsureVariable($technical, 'EnergieflussNetzkW', 'Netzleistung', 2, '~Power', 0.0, 310);
|
||||
$flowBase = enelixDemoEnsureVariable($technical, 'EnergieflussGrundlastkW', 'Haus-Grundlast', 2, '~Power', 0.0, 320);
|
||||
$flowBoiler1 = enelixDemoEnsureVariable($technical, 'EnergieflussBoiler1kW', 'Boiler 1', 2, '~Power', 0.0, 330);
|
||||
$flowBoiler2 = enelixDemoEnsureVariable($technical, 'EnergieflussBoiler2kW', 'Boiler 2', 2, '~Power', 0.0, 340);
|
||||
$flowDryer = enelixDemoEnsureVariable($technical, 'EnergieflussEntfeuchterkW', 'Entfeuchter', 2, '~Power', 0.0, 350);
|
||||
$flowHouse = enelixDemoEnsureVariable($technical, 'DiagrammHausverbrauchkW', 'Hausverbrauch gesamt', 2, '~Power', 0.0, 360);
|
||||
$flowLoads = enelixDemoEnsureVariable($technical, 'DiagrammVerbraucherkW', 'Geregelte Verbraucher', 2, '~Power', 0.0, 370);
|
||||
foreach ([
|
||||
$flowPv, $flowGrid, $flowBase, $flowBoiler1,
|
||||
$flowBoiler2, $flowDryer, $flowHouse, $flowLoads,
|
||||
] as $flowVariableId) {
|
||||
IPS_SetHidden($flowVariableId, true);
|
||||
}
|
||||
|
||||
foreach ([$boiler11, $boiler12, $boiler21, $boiler22, $dryContact] as $actorId) {
|
||||
IPS_SetVariableCustomAction($actorId, $actorScript);
|
||||
}
|
||||
@@ -148,19 +166,24 @@ function enelixDemoInstall(): array
|
||||
|
||||
$energyDistribution = enelixDemoEnsureInstance(
|
||||
$dashboard,
|
||||
'Energieverteilung',
|
||||
'Energieverteilung',
|
||||
'EnergieverteilungNativ',
|
||||
'Energiefluss',
|
||||
ENELIX_DEMO_ENERGY_DISTRIBUTION_MODULE,
|
||||
10
|
||||
);
|
||||
enelixDemoConfigureEnergyDistribution($energyDistribution, [
|
||||
enelixDemoEnergyNode($pvDisplay, 'PV-Anlage', 'solar'),
|
||||
enelixDemoEnergyNode($grid, 'Stromnetz', 'grid'),
|
||||
enelixDemoEnergyNode($base, 'Haus-Grundlast', 'consumer'),
|
||||
enelixDemoEnergyNode($boiler1Power, 'Boiler 1', 'consumer', $temp1),
|
||||
enelixDemoEnergyNode($boiler2Power, 'Boiler 2', 'consumer', $temp2),
|
||||
enelixDemoEnergyNode($dryerPower, 'Entfeuchter', 'consumer'),
|
||||
enelixDemoEnergyNode($flowPv, 'PV-Anlage', 'solar'),
|
||||
enelixDemoEnergyNode($flowGrid, 'Stromnetz', 'grid'),
|
||||
enelixDemoEnergyNode($flowBase, 'Haus-Grundlast', 'consumer'),
|
||||
enelixDemoEnergyNode($flowBoiler1, 'Boiler 1', 'consumer', $temp1),
|
||||
enelixDemoEnergyNode($flowBoiler2, 'Boiler 2', 'consumer', $temp2),
|
||||
enelixDemoEnergyNode($flowDryer, 'Entfeuchter', 'consumer'),
|
||||
]);
|
||||
IPS_SetHidden($energyDistribution, false);
|
||||
$oldEnergyDistribution = enelixDemoFind($dashboard, 'Energieverteilung');
|
||||
if ($oldEnergyDistribution > 0 && $oldEnergyDistribution !== $energyDistribution) {
|
||||
IPS_SetHidden($oldEnergyDistribution, true);
|
||||
}
|
||||
|
||||
foreach ([$boiler1, $boiler2] as $boilerId) {
|
||||
IPS_RequestAction($boilerId, 'Mindesttemperatur', 42.0);
|
||||
@@ -194,16 +217,37 @@ function enelixDemoInstall(): array
|
||||
}
|
||||
IPS_RequestAction($manager, 'Aktiv', true);
|
||||
|
||||
enelixDemoLinkInstanceVariables($boiler1View, $boiler1, $temp1);
|
||||
enelixDemoLinkInstanceVariables($boiler2View, $boiler2, $temp2);
|
||||
$boiler1List = enelixDemoEnsureInstance(
|
||||
$dashboard,
|
||||
'Boiler1Liste',
|
||||
'Boiler 1',
|
||||
ENELIX_DEMO_DUMMY_MODULE,
|
||||
110
|
||||
);
|
||||
$boiler2List = enelixDemoEnsureInstance(
|
||||
$dashboard,
|
||||
'Boiler2Liste',
|
||||
'Boiler 2',
|
||||
ENELIX_DEMO_DUMMY_MODULE,
|
||||
120
|
||||
);
|
||||
enelixDemoConfigure($boiler1List, []);
|
||||
enelixDemoConfigure($boiler2List, []);
|
||||
enelixDemoLinkInstanceVariables($boiler1List, $boiler1, $temp1);
|
||||
enelixDemoLinkInstanceVariables($boiler2List, $boiler2, $temp2);
|
||||
IPS_SetHidden($boiler1View, true);
|
||||
IPS_SetHidden($boiler2View, true);
|
||||
IPS_SetHidden($boiler1, false);
|
||||
IPS_SetHidden($boiler2, false);
|
||||
IPS_SetHidden($boiler1, true);
|
||||
IPS_SetHidden($boiler2, true);
|
||||
|
||||
foreach (['Boiler1Link', 'Boiler2Link'] as $oldLinkIdent) {
|
||||
$oldLink = enelixDemoFind($dashboard, $oldLinkIdent);
|
||||
if ($oldLink > 0) {
|
||||
IPS_SetHidden($oldLink, true);
|
||||
}
|
||||
}
|
||||
|
||||
enelixDemoEnsureLink($dashboard, 'ManagerLink', 'Manager', $manager, 100);
|
||||
enelixDemoEnsureLink($dashboard, 'Boiler1Link', 'Boiler 1', $boiler1, 110);
|
||||
enelixDemoEnsureLink($dashboard, 'Boiler2Link', 'Boiler 2', $boiler2, 120);
|
||||
enelixDemoEnsureLink($dashboard, 'EntfeuchterLink', 'Entfeuchter', $dryer, 130);
|
||||
enelixDemoEnsureLink($simulation, 'Boiler1TemperaturLink', 'Boiler 1 Temperatur', $temp1, 70);
|
||||
enelixDemoEnsureLink($simulation, 'Boiler2TemperaturLink', 'Boiler 2 Temperatur', $temp2, 80);
|
||||
@@ -213,7 +257,21 @@ function enelixDemoInstall(): array
|
||||
$boiler1Power, $boiler2Power, $dryerPower,
|
||||
$pvEnergy, $houseEnergy, $gridImportEnergy, $gridExportEnergy,
|
||||
$temp1, $temp2,
|
||||
$flowPv, $flowGrid, $flowBase, $flowBoiler1, $flowBoiler2, $flowDryer,
|
||||
$flowHouse, $flowLoads,
|
||||
]);
|
||||
enelixDemoEnsureChart($history, 'LeistungsdiagrammNativ', 'Leistungsverlauf', [
|
||||
enelixDemoChartDataset($flowPv, 'PV', '#f4c542', '~Power'),
|
||||
enelixDemoChartDataset($flowHouse, 'Hausverbrauch', '#2bb673', '~Power'),
|
||||
enelixDemoChartDataset($flowLoads, 'Geregelte Verbraucher', '#2786ac', '~Power'),
|
||||
enelixDemoChartDataset($flowGrid, 'Netzleistung', '#e95d5d', '~Power'),
|
||||
], 10);
|
||||
enelixDemoEnsureChart($history, 'EnergiediagrammNativ', 'Kumulierte Energien', [
|
||||
enelixDemoChartDataset($pvEnergy, 'PV', '#f4c542', '~Electricity'),
|
||||
enelixDemoChartDataset($houseEnergy, 'Hausverbrauch', '#2bb673', '~Electricity'),
|
||||
enelixDemoChartDataset($gridImportEnergy, 'Netzbezug', '#e95d5d', '~Electricity'),
|
||||
enelixDemoChartDataset($gridExportEnergy, 'Einspeisung', '#38a3db', '~Electricity'),
|
||||
], 20);
|
||||
enelixDemoConfigureVisualization($root, $energyDistribution);
|
||||
enelixDemoTick('Install');
|
||||
|
||||
@@ -297,6 +355,14 @@ function enelixDemoTick(string $source = 'Manual'): void
|
||||
SetValue(enelixDemoRequiredId($dashboard, 'Boiler1Leistung'), (float) $boiler1);
|
||||
SetValue(enelixDemoRequiredId($dashboard, 'Boiler2Leistung'), (float) $boiler2);
|
||||
SetValue(enelixDemoRequiredId($dashboard, 'EntfeuchterLeistung'), (float) $dryer);
|
||||
SetValue(enelixDemoRequiredId($technical, 'EnergieflussPVkW'), round($pv / 1000.0, 3));
|
||||
SetValue(enelixDemoRequiredId($technical, 'EnergieflussNetzkW'), round($grid / 1000.0, 3));
|
||||
SetValue(enelixDemoRequiredId($technical, 'EnergieflussGrundlastkW'), round($base / 1000.0, 3));
|
||||
SetValue(enelixDemoRequiredId($technical, 'EnergieflussBoiler1kW'), round($boiler1 / 1000.0, 3));
|
||||
SetValue(enelixDemoRequiredId($technical, 'EnergieflussBoiler2kW'), round($boiler2 / 1000.0, 3));
|
||||
SetValue(enelixDemoRequiredId($technical, 'EnergieflussEntfeuchterkW'), round($dryer / 1000.0, 3));
|
||||
SetValue(enelixDemoRequiredId($technical, 'DiagrammHausverbrauchkW'), round($house / 1000.0, 3));
|
||||
SetValue(enelixDemoRequiredId($technical, 'DiagrammVerbraucherkW'), round($power / 1000.0, 3));
|
||||
|
||||
$history = enelixDemoRequiredId($root, 'Historie');
|
||||
$energyIds = [
|
||||
@@ -313,11 +379,6 @@ function enelixDemoTick(string $source = 'Manual'): void
|
||||
enelixDemoAddEnergy($energyIds['export'], max(0.0, -$grid), $hours);
|
||||
}
|
||||
|
||||
$chartUpdated = enelixDemoRequiredId($technical, 'LetztesDiagrammUpdate');
|
||||
if ($source !== 'Timer' || time() - (int) GetValue($chartUpdated) >= 10) {
|
||||
enelixDemoUpdateCharts($history, [$pvId, $houseId, $gridId], $energyIds);
|
||||
SetValue($chartUpdated, time());
|
||||
}
|
||||
}
|
||||
|
||||
function enelixDemoRenderFlow(array $state): string
|
||||
@@ -378,6 +439,7 @@ function enelixDemoValidateRuntime(): void
|
||||
ENELIX_DEMO_MANAGER_MODULE,
|
||||
ENELIX_DEMO_BOILER_MODULE,
|
||||
ENELIX_DEMO_SINGLE_MODULE,
|
||||
ENELIX_DEMO_DUMMY_MODULE,
|
||||
ENELIX_DEMO_ENERGY_DISTRIBUTION_MODULE,
|
||||
] as $moduleId) {
|
||||
if (!in_array($moduleId, $available, true)) {
|
||||
@@ -451,6 +513,53 @@ function enelixDemoEnsureVariable(int $parent, string $ident, string $name, int
|
||||
return $id;
|
||||
}
|
||||
|
||||
function enelixDemoEnsureChart(
|
||||
int $parent,
|
||||
string $ident,
|
||||
string $name,
|
||||
array $datasets,
|
||||
int $position
|
||||
): int {
|
||||
$id = enelixDemoFind($parent, $ident);
|
||||
if ($id === 0) {
|
||||
$id = IPS_CreateMedia(4);
|
||||
IPS_SetParent($id, $parent);
|
||||
IPS_SetIdent($id, $ident);
|
||||
}
|
||||
enelixDemoRequireType($id, 5);
|
||||
if ((int) IPS_GetMedia($id)['MediaType'] !== 4) {
|
||||
throw new RuntimeException('Medientyp-Konflikt bei ' . $ident);
|
||||
}
|
||||
IPS_SetName($id, $name);
|
||||
IPS_SetPosition($id, $position);
|
||||
IPS_SetHidden($id, false);
|
||||
IPS_SetMediaFile($id, 'media/' . $id . '.chart', false);
|
||||
IPS_SetMediaContent(
|
||||
$id,
|
||||
base64_encode(json_encode(['datasets' => $datasets], JSON_THROW_ON_ERROR))
|
||||
);
|
||||
return $id;
|
||||
}
|
||||
|
||||
function enelixDemoChartDataset(
|
||||
int $variableId,
|
||||
string $title,
|
||||
string $strokeColor,
|
||||
string $profile
|
||||
): array {
|
||||
return [
|
||||
'variableID' => $variableId,
|
||||
'fillColor' => 'clear',
|
||||
'strokeColor' => $strokeColor,
|
||||
'timeOffset' => 0,
|
||||
'visible' => true,
|
||||
'title' => $title,
|
||||
'type' => 'line',
|
||||
'side' => 'left',
|
||||
'profile' => $profile,
|
||||
];
|
||||
}
|
||||
|
||||
function enelixDemoEnsureScript(int $parent, string $ident, string $name, string $content, int $position): int
|
||||
{
|
||||
$id = enelixDemoFind($parent, $ident);
|
||||
@@ -642,12 +751,12 @@ function enelixDemoEnergyNode(
|
||||
return [
|
||||
'VariableConfigType' => 0,
|
||||
'VariableID' => $variableId,
|
||||
'SecondaryVariableID' => 0,
|
||||
'SecondaryVariableID' => 1,
|
||||
'Name' => $name,
|
||||
'Type' => $type,
|
||||
'Grouped' => false,
|
||||
'CalculationType' => 0,
|
||||
'InfoVariableID' => $infoVariableId,
|
||||
'InfoVariableID' => $infoVariableId > 0 ? $infoVariableId : 1,
|
||||
'Invert' => false,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user